[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Odd Behavior: $SHLVL decreases in some situations with a pipe
From: |
H. Thiele |
Subject: |
Re: Odd Behavior: $SHLVL decreases in some situations with a pipe |
Date: |
Wed, 29 Jun 2022 07:37:37 +0200 (CEST) |
User-agent: |
ALL-INKL Webmail 2.11 |
Hello Chet Ramey,
Chet Ramey wrote on 27.06.2022 16:16 (GMT +02:00):
> > Bash Version: 5.1
> > Patch Level: 16
> > Release Status: release
> >
> > Description:
> > In some situations (see Repeat-By) the value of the $SHLVL (Shell Level)
> > variable may
> > unexpectedly decrease by 1, e.g. when the stdout output of "printenv" is
> > redirected to
> > via a pipe.
>
> As you surmise, the behavior is related to bash optimizing away forks and
> using an implicit `exec' in the pipeline. I changed this particular case
> back last September as the result of
>
> https://lists.gnu.org/archive/html/help-bash/2020-10/msg00012.html
>
> which contains a pretty good discussion of the issue.
>
>
Thank you very much for the reply and the hint. I tried out the new 5.2 RC
version of bash and I can confirm the behavior for the SHLVL variable is
indeed more traditional again.
In my case it was purely a cosmetic "problem" though, that just slightly
had me confused. I had no idea it could have more grave consequences like
for the other user.
Now, I'm patiently looking forward to the release version of 5.2. :-)
With best regards,
H. Thiele