[lsb-discuss] Re: /usr/bin/env bash

Mark Brown bmark at us.ibm.com
Tue Aug 17 08:04:50 PDT 2004


George-

> If I remember correctly the UNIX specifications avoid specifying lines 
> like "#!/bin/sh" at the beginning of a shell script.   Is "/usr/bin/env" 

> a solution to this problem?

History: While *everyone* agreed this was common practice, we just
could *not* get agreement on a set of wording that made a consensus.
You have to describe a lot of things (exec(), the shell, where the shell
is located, argument passing, etc) just so. Getting the wording Right
was a Very Hard thing, even though we all knew what we wanted.

A "Strictly Conforming" POSIX shell script cannot rely on #! being 
anything
other than a comment, and should not use it at all, for maximum 
portability.
POSIX does not prohibit OSes doing #!, but does not specify it in any way,
not even through reservation of the token.

The Single UNIX Specification reserves #! so that implementations that
support exec() handling shell scripts, can do so without being in 
violation.
The teminology is that if a shell script has #! as the first two chars,
the implementation may do undefined things.

I think the LSB should at least say what the SUS says in this area, since
it allows what everybody wants. Since the LSB only covers Linux
(and not a variety of Unices and people thiniing about non-Unix OSes of 
the
future that Might Want To Do Something Different) I think that you are 
free to actually
specify #! completely -- I can get you copies of the wording that came 
closest
to passing in SUS (complete with mailing list arguments for & against).

As for /usr/bin/env, you are still executing it on the command line, just 
as
if you are doing 
        $ sh _args_
so it doesn't really seem to solve the problem, unless I'm just being 
dense.





-------------------
Mark S. Brown 
STSM, UNIX/Linux OS Standards
IBM Systems Group, Linux Technology Center
bmark at us.ibm.com




More information about the lsb-discuss mailing list