On 6/20/18 9:25 AM, Tomáš Čech wrote:
> Hi,
> 
> 
> when comparing strange behaviors of different shell implementations Tomas
> Janousek found this bug
> 
> When using BASH as sh shell...
> 
>  $ ls -l /bin/sh
>  lrwxrwxrwx 1 root root 4 Jun 13 16:25 /bin/sh -> bash
> 
> ...internal shell command `set' propagates environment variable to the
> process its running:
> 
>  $ /bin/sh
>  sh-4.4$ VARIABLE=value set -o noglob
>  sh-4.4$ env | grep VARIABLE
>  VARIABLE=value
>  sh-4.4$

Posix requires this behavior, which dates back to the Bourne shell, for
assignment statements that precede special builtins:

http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_14

It used to require the same behavior for assignment statements preceding
shell function calls, but that was removed in the most recent update.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    c...@case.edu    http://tiswww.cwru.edu/~chet/

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to