Re: #! incompatible -- binfmt_script.c broken?

Matthias Andree
2002-12-05T11:31:25Z

On Wed, 04 Dec 2002, Horst von Brand wrote:

> Alex Riesen <Alexander.Riesen@synopsys.com> said:
>
> [...]
>
> > looks correct. The interpreter (/bin/sh) has got everything after
> > its name. IOW: "-- # -*- perl -*- -T"
> > It's just solaris' shell (/bin/sh) just ignores options starting with
> > "--". And freebsd's as well.
>
> And Linux's too. Try it.

Is there the "Linux's /bin/sh"? I believe most distributions use GNU
bash for /bin/sh, and that certainly does NOT ignore these, but parse.

The problem is that binfmt_script.c does not split the remainder of the
line at whitespace.

Assuming your current working directory does not have files that match
-*-:

$ /bin/sh '-- # -*- perl -*- -T'
/bin/sh: -- # -*- perl -*- -T: invalid option
Usage: /bin/sh [GNU long option] [option] ...
/bin/sh [GNU long option] [option] script-file ...
GNU long options:
--debug
...

$ /bin/bash -- # -*- perl -*- -T
$

$ /usr/bin/ksh '-- # -*- perl -*- -T'
/usr/bin/ksh: /usr/bin/ksh: --: unknown option

$ /usr/bin/ksh -- # -*- perl -*- -T
$

$ /usr/bin/zsh '-- # -*- perl -*- -T'
/usr/bin/zsh: no such option: # _*_ perl _*_ _T

$ /usr/bin/zsh -- # -*- perl -*- -T
$

--
Matthias Andree