Subject: Re: HELP : some newbie questions
To: None <netbsd-help@NetBSD.ORG>
From: CyberPeasant <listread@bedford.net>
List: netbsd-help
Date: 02/14/1998 09:20:21
>                                                      All standard, current
> unix shells are programmed to look for a special format comment line at the
> beginning of any script and if it points to a valid shell to switch to that
> shell instead of processing the script themselves.

This statement appears to be incorrect in all respects.

No shell to my knowledge looks for "#! /interpreter". This is a function
of the execve(2) system call; i.e. the job is done by the kernel, not
a shell.

The #! /interpreter is not a command line to a shell; it is a comment.
It is because it is a comment to the interpeter, that it works at all.

Shells usually do not interpret script files "themselves", but
instead create a new process. Usually it takes a special effort to
make a shell interpret a script in its own context, which is
called "sourcing".

There is no concept of "validity" attaching to the interpreter specified,
beyond the requirement that it be executable by the user, and not setuid/
setgid (in the usual configuration). The interpreter could be a shell
script itself, for that matter. It helps if '#' is the interpreter's
comment character.

I will recant these statements when shown contradicting source code.
/usr/src/bin/csh/exec.c makes interesting reading in this context.
So does /usr/src/sys/kern/exec_script.c

DV
-- 
PGP public key:  finger djv@bedford.net

       --== There are Greeks in that horse! I can hear them! ==--