Re: variable set in exec'ing shell cannot be unset by child shell
From:
Greg Wooledge
Subject:
Re: variable set in exec'ing shell cannot be unset by child shell
Date:
Fri, 13 Oct 2023 15:52:26 -0400
On Fri, Oct 13, 2023 at 02:21:59PM -0400, Dale R. Worley wrote:
> I was too lazy to chew through your example, but I coded an instance of
> your description (above), and it does not show the dubious behavior that
> you report. Specifically,
>
> $ bash -version
> GNU bash, version 5.1.0(1)-release (x86_64-redhat-linux-gnu)
> ...
> $ ls -l
> total 20
> -rwxr-xr-x. 1 worley worley 112 Oct 13 14:14 inner
> -rw-r--r--. 1 worley worley 113 Oct 13 14:13 middle
> -rw-r--r--. 1 worley worley 123 Oct 13 14:12 outer
> $ cat inner
> echo "Value in ./inner at the beginning: $OUTSIDE"
>
> unset OUTSIDE
>
> echo "Value in ./inner at the end: $OUTSIDE"
I tried to understand the question as well. I got as far as realizing
there were *three* scripts, not two as originally stated (your example
agrees). But the OP's third script wraps around and re-invokes the
first one. It's an ouroboros snake.
Your example doesn't circle around in the same way, so I don't know how
faithfully it's reproducing the original question.
Once I realized there was an infinite loop of scripts eating their own
tails, I gave up trying to understand any further. Too complicated for
me.