On Fri, Jan 02, 2004 at 10:20:56AM +0530, Amey Gokhale wrote:
> >This basically means that the start of your script is incorrect.
> >Remove the first line. The first line should always be a "#!/bin/bash"
>
> below is a script ... which has many lines as comments at the start.
> still it works.
I did some experiments with a test script, and here's what I found. I
think this behaviour depends a lot on the way each distribution of
GNU/Linux handles shell scripts. I use a Debian box, and /bin/bash
seems to be the _default handler_ for shell scripts, which is used /if
the script does not specify a handler/. How do we test this?
>From the bash manpage
Shell Variables
BASH Expands to the full file name used to invoke this instance of bash.
So I wrote a script with single line in it:
echo $BASH
Since I didn't specify a handler, the result was "/bin/bash"
Change that to:
#!/bin/csh
echo $BASH
This time the result was "BASH: Undefined variable." This happened
because I do have the real csh installed on my system, which was
invoked correctly.
Now by Debian policy, /bin/csh is a symlink to the real csh somewhere
else. I changed that so that /bin/csh points to /bin/bash. This time
the result was "/bin/csh". This was because now the script was
processed by bash masquerading as csh.
Moral of the story? Don't conclude non-existing features by looking at
default behaviours ... read the manpages instead!
Sameer.
--
Research Scholar, KReSIT, IIT Bombay
http://www.it.iitb.ac.in/~sameerds/
--
http://mm.ilug-bom.org.in/mailman/listinfo/linuxers