bug-bash
[Top][All Lists]
Advanced

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

Re: variable set in exec'ing shell cannot be unset by child shell


From: Chet Ramey
Subject: Re: variable set in exec'ing shell cannot be unset by child shell
Date: Mon, 16 Oct 2023 10:34:43 -0400
User-agent: Mozilla Thunderbird

On 10/14/23 12:46 AM, Martin D Kealey wrote:

Respectfully I must disagree.

This aspect of Bash's behaviour has a very long historical precedent.

Back when I used the Bourne Shell we didn't have `local`, so we used to
write `var= func` to make sure that `func` couldn't mess with *our* `var`.

This is a POSIX special builtin, so the desire for a local variable is the
same, but with a special twist that makes it not work. In that case, the
variable assignment is required to propagate to the shell global variable
table, as if

VAR=outside . filename

were

VAR=outside; . filename

That isn't the same with a non-special builtin like `alias'.

Bash doesn't treat the so-called special builtins any differently unless
it's in posix mode.

--
``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/




reply via email to

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