bug-bash
[Top][All Lists]
Advanced

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

Re: Detecting invocation as /bin/sh ?


From: Chet Ramey
Subject: Re: Detecting invocation as /bin/sh ?
Date: Mon, 29 Sep 2014 15:51:45 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:24.0) Gecko/20100101 Thunderbird/24.6.0

On 9/26/14, 4:29 PM, Alexandre Ferrieux wrote:
> 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.

Posix mode was never intended to turn bash into a shell that provides only
what Posix specifies and nothing more.  It makes bash conform to Posix by
changing things where the default mode differs from what Posix specifies.
Posix allows this, and allows extensions, and every shell that claims
Posix conformance (except perhaps `posh') offers extensions beyond minimal
Posix features.

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/



reply via email to

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