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: Grisha Levit
Subject: Re: variable set in exec'ing shell cannot be unset by child shell
Date: Fri, 13 Oct 2023 14:59:34 -0700

On Fri, Oct 13, 2023, 10:03 Ti Strga <wearyofallthiscrap@gmail.com> 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 human to read.  Copy-and-exec
> makes the top-level scripts cleaner IMHO.
>

IMHO you'd be better off just putting a `{` line at the start and `}` line
at the end of your scripts, and avoid a whole host of other potential
problems. (Do you make a separate holding directory for each run of the
outer script? If so, what happens if someone starts another copy after
making changes? If not, how do you clean it up? Etc.)

So what's up with 'unset OUTSIDE' not actually doing that?  We've got a
> workaround, but I'm still confused as to what went wrong to begin with.
>

A simpler reproducer:

$ echo 'unset V; echo V=$V' > t.sh
$ V=X; V=Y . t.sh
V=X

I agree, this is isn't really expected behavior. But you can unset the
variable once more to really clear it.

>


reply via email to

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