Mike Leone on 23 Apr 2010 12:01:24 -0700

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] Bash script problems - no "function" support?

brent timothy saner had this to say:
> Hash: SHA1
> On 04/23/10 13:35, Mike Leone wrote:
>> So why are functions not being recognized on my system? Ubuntu 8.04. The 
>> shell for this user is explicitly set to "/bin/bash" in /etc/passwd.
> run it with bash -x script.sh

Here's the test script:

$ more test2.sh

function myfunc {
   echo "hello world"

and here's what happens:

$ sh test2.sh
test2.sh: 3: function: not found
hello world
test2.sh: 5: Syntax error: "}" unexpected

$ bash -n test2.sh

$ bash -x test2.sh
+ myfunc
+ echo 'hello world'
hello world


> and let us know what it spits out. i don't expect it to tell us much,
> especially since we already know it's a problem with recognizing
> functions, but we're starting at step 1, which is usually a good place
> to start.
> does it work with any other users? 


> also, try running test.sh with bash instead of sh. it worked for me fine
> on an 8.04.4 box, and it appears it does, in fact, link to /bin/bash,
> but you never know.

Using bash worked ...

$ bash test2.sh
hello world

So ... what? I have a weird link somewhere? Is the link called "sh" 
fubarred up? How can I tell?
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug