using #! and a different shell
George Robbins
grr at cbmvax.commodore.com
Fri Feb 22 20:22:19 AEST 1991
In article <1991Feb21.172233.8160 at aplcen.apl.jhu.edu> kjh at visual1.jhuapl.edu (Kenneth J. Heeres) writes:
>
> If I am writing my own shell command processor and I use the
> #! pathname
> capability to implicitly invoke it, what happens to the arguments that
> were passed to the script???
The outline is described in the man entry for execve().
The actual behavior of the Berkeley exec code sets up the
arguments as below and leaves stdin assigned to the script
at the line folling the #! stuff.
first arg: interpreter specified after #!
next arg: all arguments specified after above,
*not* parsed for delimiters,
skipped if no arguments
next arg: command from command line
next arg: first argument from command line, if any
next arg: and so on...
The non-parsed arguments from the #! line can be
unfortunate since some programs you might wish to
use as "interpreters" prefer their arguments parsed.
ie "#! awk -f" does what's expected, "#! awk -F: -f" doesn't.
In non-hacked AT&T flavors of Unix, the setup is handled
by the shell, but the results should be equivalent.
--
George Robbins - now working for, uucp: {uunet|pyramid|rutgers}!cbmvax!grr
but no way officially representing: domain: grr at cbmvax.commodore.com
Commodore, Engineering Department phone: 215-431-9349 (only by moonlite)
More information about the Comp.unix.wizards
mailing list