[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: propagating environment variable via internal command
From: |
Chet Ramey |
Subject: |
Re: propagating environment variable via internal command |
Date: |
Wed, 20 Jun 2018 10:42:07 -0400 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 |
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 chet@case.edu http://tiswww.cwru.edu/~chet/
signature.asc
Description: OpenPGP digital signature