Babu Kalakrishnan forced the electrons to say:
> If we execute a script using the "." construct, does it ignore the shebang 
> line in the script altogether ? 

IIRC, the shebang line in interpreted by the kernel (or is the
loader?) while trying to run the program. AFAIR, the first two bytes
of an executable says its type or something, and some wise kids from
(MIT? UCB?) somewhere devised this idea to give a two byte signature to
interpreted code as well.

The whoever, when it sees the shebang, will parse the rest of the first
line, and fill an argv array, with the last element being the filename
itself. So, a shebang line like:

#! /usr/bin/awk -f

will cause this fellow to use a argv array with argv[0] : /usr/bin/awk,
argv[1] : -f, argv[2] : the script file name, argv[4] : NULL, and then
call execv().

The idea is, the awk binary, when parsing this file, will ignore the
shebang line, since for awk, that line, which begins with a '#', is
a comment.

There was a technique to use /usr/bin/env to allow shebang lines
for interpreted languages that do not use '#' as comment starters. I
forgot how.

That also means that there is a slight difference in running a shell
script with the 'x' bit on and directly from command line ( as ./script)
and as sh ./script.

In contrast, the '.' construct is interpreted by the shell itself, in the
current shell.

> What would happen if I had a csh script  called myscript with a startline 
> that says #!/bin/csh and try to execute it under bash as ". myscript" ?

Because of the syntax differences between csh and bash, . myscript might
fail. In which case, so will sh ./myscript. But, if you have /bin/csh
on your computer, chmod +x the script and ./myscript will succeed.

Binand

PS: I wish someone shed some more light on the exact concept of the shebang.
Psst..., Arun??

-- 
The prompt for all occasions:
export PS1="F:\$(pwd | tr '/[a-z]' '\134\134[A-Z]')> "
--------------- Binand Raj S. ([EMAIL PROTECTED])


-----------------------------------------------------------------------
The LIH mailing list archives are available at:
http://lists.linux-india.org/cgi-bin/wilma/linux-india-help

Reply via email to