[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: shebang (was Re: systemd - some more considerations)



Hi,

Thorsten Glaser <t.glaser@tarent.de> writes:
> On Fri, 4 Apr 2014, Chow Loong Jin wrote:
>
>> Are you sure about this?
>
> Yes.
>
>> Some references would be helpful. I can't seem to find anything on this through
>
> Sure. I’ve patched mksh to use “#?” ipv “#!” as shebang, to
> simulate a kernel not supporting the shebang:
[...]
> Try duckduckgoïng instead ☻ or searching POSIX, or something.

I tried and found that POSIX says the shell shall try execve(), and if
that fails 'the shell shall execute a command equivalent to having a
shell invoked with the pathname resulting from the search as its first
operand, with any remaining arguments passed to the new shell, except
that the value of "$0" in the new shell may be set to the command
name.'[1] No #! involved.

  [1] <http://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_09_01_01>

Furthermore Wikipedia says "For this reason and because POSIX does not
standardize path names, POSIX does not standardize the feature."[2].

  [2] <http://en.wikipedia.org/wiki/Shebang_%28Unix%29#Portability>

I'm interested where POSIX says what you are sure it says (that the
shell is responsible for evaluating #!).

> Also, “man mksh” look for EXECSHELL (which is the interpreter the
> shell uses if the script doesn’t even have a shebang).

I don't think the manual for a not commonly used shell is a good
reference...

Ansgar


Reply to: