Re: Shebang - why are parameters not splitted on whitespace?
From: AmÃrico Wang
Date: Wed Dec 03 2008 - 10:57:01 EST
On Wed, Dec 3, 2008 at 3:14 PM, Geralt <usr.gentoo@xxxxxxxxxxxxxx> wrote:
> I've just noticed, that it's not possible to use more than one
> parameter in a shebang on linux, because everything following the
> executable path in the shebang is treated as one parameter, so for
> #!/bin/awk --re-interval -f
> in a script called "test.awk" results in a call likes this:
> /bin/awk "--re-interval -f" ./test.awk
> when running it with "./test.awk".
> Is there any reason why the parameters are not split before passing
> them on to the program?
I think this behavior is different on different platforms, you can
find some clues
in man page of execve(2):
The semantics of the optional-arg argument of an interpreter script
vary across implementations. On Linux, the entire string following the
interpreter name is passed as a single argument to the interpreter, and
this string can include white space. However, behavior differs on some
other systems. Some systems use the first white space to terminate
optional-arg. On some systems, an interpreter script can have multiple
arguments, and white spaces in optional-arg are used to delimit the
It seems that POSIX doesn't specify this.
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/