Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!elroy.jpl.nasa.gov!ncar!zaphod.mps.ohio-state.edu!unix.cis.pitt.edu!dsinc!bagate!cbmvax!grr From: grr@cbmvax.commodore.com (George Robbins) Newsgroups: comp.unix.wizards Subject: Re: using #! and a different shell Message-ID: <19226@cbmvax.commodore.com> Date: 22 Feb 91 09:22:19 GMT References: <1991Feb21.172233.8160@aplcen.apl.jhu.edu> Reply-To: grr@cbmvax.commodore.com (George Robbins) Organization: Commodore, West Chester, PA Lines: 33 In article <1991Feb21.172233.8160@aplcen.apl.jhu.edu> kjh@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@cbmvax.commodore.com Commodore, Engineering Department phone: 215-431-9349 (only by moonlite) Brought to you by Super Global Mega Corp .com