From: Geralt <usr.gentoo@googlemail.com>
To: linux-kernel@vger.kernel.org
Subject: Re: Shebang - why are parameters not splitted on whitespace?
Date: Wed, 3 Dec 2008 18:29:55 +0100 [thread overview]
Message-ID: <fbdd0e50812030929s2d573981k46757c1b706f4cd5@mail.gmail.com> (raw)
In-Reply-To: <fbdd0e50812030929q65d2e805y49094dd67209be7e@mail.gmail.com>
On Wed, Dec 3, 2008 at 4:56 PM, Américo Wang <xiyou.wangcong@gmail.com> wrote:
> On Wed, Dec 3, 2008 at 3:14 PM, Geralt <usr.gentoo@googlemail.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/
next prev parent reply other threads:[~2008-12-03 17:30 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-03 15:14 Geralt
2008-12-03 15:56 ` Américo Wang
[not found] ` <fbdd0e50812030929q65d2e805y49094dd67209be7e@mail.gmail.com>
2008-12-03 17:29 ` Geralt [this message]
2008-12-06 1:04 ` Américo Wang
2008-12-06 5:41 ` Valdis.Kletnieks
2008-12-06 12:02 ` Geralt
2008-12-06 21:14 ` Aaron Cohen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=fbdd0e50812030929s2d573981k46757c1b706f4cd5@mail.gmail.com \
--to=usr.gentoo@googlemail.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®