[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <fbdd0e50812030929s2d573981k46757c1b706f4cd5@mail.gmail.com>
Date: Wed, 3 Dec 2008 18:29:55 +0100
From: Geralt <usr.gentoo@...glemail.com>
To: linux-kernel@...r.kernel.org
Subject: Re: Shebang - why are parameters not splitted on whitespace?
On Wed, Dec 3, 2008 at 4:56 PM, Américo Wang <xiyou.wangcong@...il.com> wrote:
> On Wed, Dec 3, 2008 at 3:14 PM, Geralt <usr.gentoo@...glemail.com> wrote:
>> Hi,
>>
>> 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
>> example
>> #!/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?
>
>
> Hello,
>
> 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
> arguments
>
> It seems that POSIX doesn't specify this.
>
> Thanks.
>
Hello,
I should have anticipated this objection :-). I'm aware that this is
not consistent among Unix operating systems (you can find more about
it here [1]), but I was specifically refering to linux in this case
and why it handles the shebang arguments as one big string and not as
single arguments for the application.
Geralt.
[1] http://www.in-ulm.de/~mascheck/various/shebang/
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists