Re: Localised variables become exposed to environment when FUNCNEST reached

2022-11-28 Thread Chet Ramey

On 11/27/22 10:55 AM, felix wrote:

Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -g -O2
uname output: Linux medium 5.10.0-19-amd64 #1 SMP Debian 5.10.149-2 
(2022-10-21) x86_64 GNU/Linux
Machine Type: x86_64-pc-linux-gnu

Bash Version: 5.2
Patch Level: 12
Release Status: release

Description:
Localised variable in a function could alter environ when FUNCNEST is 
reached


Thanks for the report. FUNCNEST is intended more as a fatal error
mechanism than a way for scripts to do flow control.

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/




Localised variables become exposed to environment when FUNCNEST reached

2022-11-27 Thread felix
Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -g -O2
uname output: Linux medium 5.10.0-19-amd64 #1 SMP Debian 5.10.149-2 
(2022-10-21) x86_64 GNU/Linux
Machine Type: x86_64-pc-linux-gnu

Bash Version: 5.2
Patch Level: 12
Release Status: release

Description:
Localised variable in a function could alter environ when FUNCNEST is 
reached

Repeat-By:
$ funcTest() { local FUNCNEST=1 LocalVar=Not\ Global;$FUNCNAME;}
$ echo $LocalVar

$ funcTest
bash: funcTest: maximum function nesting level exceeded (1)
$ echo $LocalVar
Not Global

( Once playing with this, don't miss to `unset FUNCNEST`! ;-)