Re: Bash-script – doesn't work in a launcher
J
dreadpiratejeff at gmail.com
Sat Dec 31 20:25:01 UTC 2011
On Sat, Dec 31, 2011 at 13:21, Johnny Rosenberg <gurus.knugum at gmail.com> wrote:
> 2011/12/31 Avi Greenbury <lists at avi.co>:
>> Johnny Rosenberg wrote:
>>> Still I wonder why it worked with the #!/bin/bash line not at the top
>>> when I ran it from a terminal, should it really…? Maybe because bash
>>> is default in a terminal?
>>
>> Exactly. When you don't specify an interpreter to use, generally the
>> current shell is used, which is probably bash.
>>
>> A line beginning #! anywhere other than the top of the script is simply
>> a comment; there's nothing parsing it to work out what to do.
>
> That's very good to know. I thought it would recognise it wherever it
> was, as long as nothing was done above it, but now I know better.
> Thanks.
Also, something to keep in mind for cases where you aren't calling a
specific shell using the #! line in a script...
check to see if /bin/sh and /bin/bash are symlinks to other shells.
For example:
bladernr at minime:~$ ll /bin/sh
lrwxrwxrwx 1 root root 4 2011-05-06 00:45 /bin/sh -> dash*
bladernr at minime:~$ ll /bin/bash
lrwxrwxrwx 1 root root 609232 2011-05-18 13:55 /bin/bash*
dash and sh behave differently from each other and from bash, so if
you write a script for bash specifically, but run using /bin/sh or
/bin/dash, you may experience some confusing, unintended
consequences...
More information about the ubuntu-users
mailing list