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

2023-10-14 Thread Martin D Kealey
On Sun, 15 Oct 2023, 02:03 Robert Elz, wrote: > Date:Sat, 14 Oct 2023 14:46:12 +1000 > From:Martin D Kealey > Message-ID: a2+3nnknhm5a+...@mail.gmail.com> > > > | Back when I used the Bourne Shell we didn't have `local`, so we used to > | write `var= func` to

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

2023-10-14 Thread Martin D Kealey
On Sun, 15 Oct 2023, 03:15 Ti Strga, wrote: > On Fri, Oct 13, 2023 at 5:59 PM Grisha Levit > wrote: > > IMHO you'd be better off just putting a `{` line at the start and `}` > line at the end of your scripts > The big weakness of the "{}" approach is that if a writer forgets to do > that,

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

2023-10-14 Thread Martin D Kealey
On Sun, 15 Oct 2023, 03:05 Greg Wooledge, wrote: > On Sat, Oct 14, 2023 at 12:55:21PM -0400, Ti Strga wrote: > > it's just the "[[ -v foo ]]" tests to see where along the cloning > process we are. > > *Shudder* > Likewise, b. If the *real* goal is to overwrite a running script with a new

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

2023-10-14 Thread Ti Strga
On Fri, Oct 13, 2023 at 5:59 PM Grisha Levit wrote: > On Fri, Oct 13, 2023, 10:03 Ti Strga wrote: >> >> [*] Alternatively, there's the trick about putting the entire script >> contents inside a compound statement to force the parser to read it all, >> but that just makes the script harder for a

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

2023-10-14 Thread Greg Wooledge
On Sat, Oct 14, 2023 at 12:55:21PM -0400, Ti Strga wrote: > it's just the "[[ -v > foo ]]" tests to see where along the cloning process we are. *Shudder* I foresee so much more pain in your future. Seriously, this is going to blow up in your face at some point. -v peeks into some incredibly

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

2023-10-14 Thread Ti Strga
On Fri, Oct 13, 2023 at 5:35 PM Chet Ramey wrote: > This is what happens. First, you have to remember that variables supplied > as temporary assignments to builtins like eval and source persist for the > entire life of that builtin's execution, and appear in the environment of > child processes

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

2023-10-14 Thread Robert Elz
Date:Sat, 14 Oct 2023 14:46:12 +1000 From:Martin D Kealey Message-ID: | 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`. If you were using the original Bourne