Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #14254

Re: propagating environment variable via internal command

From Chet Ramey <chet.ramey@case.edu>
Newsgroups gnu.bash.bug
Subject Re: propagating environment variable via internal command
Date 2018-06-20 10:42 -0400
Message-ID <mailman.2298.1529505743.1292.bug-bash@gnu.org> (permalink)
References <20180620132525.enl5mlgyce54e4vc@doom>

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

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/

Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread


Thread

Re: propagating environment variable via internal command Chet Ramey <chet.ramey@case.edu> - 2018-06-20 10:42 -0400

csiph-web