1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00

Decrease SHLVL before doing 'exec' from main shell

Problem:

$ exec ksh
$ echo $SHLVL
2
$ exec ksh
$ echo $SHLVL
3
$ exec ksh
$ echo $SHLVL
4

...etc. SHLVL is supposed to acount the number of shell processes
that you need to exit before you get logged out. Since ksh was
replacing itself with a new shell in the same process using 'exec',
SHLVL should not increase.

src/cmd/ksh93/bltins/misc.c: b_exec():
- When about to replace the shell and we're not in a subshell,
  decrease SHLVL to cancel out a subsequent increase by the
  replacing shell. Bash and zsh also do this.
This commit is contained in:
Martijn Dekker 2021-05-19 00:02:49 +02:00
parent c828ea8d0d
commit e5e1d4b53e
4 changed files with 15 additions and 3 deletions

4
NEWS
View file

@ -3,6 +3,10 @@ For full details, see the git log at: https://github.com/ksh93/ksh
Any uppercase BUG_* names are modernish shell bug IDs.
2021-05-18:
- Fixed SHLVL so that replacing ksh by itself (exec ksh) will not increase it.
2021-05-13:
- Fixed a bug with 'test -t 1' that was introduced on 2021-04-26: