[Top][All Lists]

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

Re: Detecting invocation as /bin/sh ?

From: Alexandre Ferrieux
Subject: Re: Detecting invocation as /bin/sh ?
Date: Fri, 26 Sep 2014 13:29:04 -0700 (PDT)
User-agent: G2/1.0

On Friday, September 26, 2014 10:00:08 AM UTC+2, Andreas Schwab wrote:
> Alexandre Ferrieux <address@hidden> writes:
> > So, what about, in bash's initialization, detecting that we are invoked as
> > "/bin/sh",
> It already does.  See (bash) Bash POSIX Mode.

Yes, it does do this detection, but too late for our concern, since things 
occur in the following order:

 (1) set_shell_name(argv[0]) => this detects "sh" and sets 'act_like_sh'
 (2) shell_initialize() => this decides to import funcs from env depending on 
flags like 'posixly_correct'
 (3) if (act_like_sh) ... sv_strict_posix ("POSIXLY_CORRECT")

So it seems the order is wrong. As a consequence, and this is confirmed by 
experience, the #!/bin/sh prefix behaves as featuristic bash.

My suggestion then is to undo that mistake.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]