[Bug 16141] New: Uniform the behaviour of $SHLVL to bash

bugzilla at busybox.net bugzilla at busybox.net
Thu Aug 1 20:18:03 UTC 2024


https://bugs.busybox.net/show_bug.cgi?id=16141

            Bug ID: 16141
           Summary: Uniform the behaviour of $SHLVL to bash
           Product: Busybox
           Version: unspecified
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P5
         Component: Other
          Assignee: unassigned at busybox.net
          Reporter: ale5000 at gmail.com
                CC: busybox-cvs at busybox.net
  Target Milestone: ---

Please uniform the behaviour of $SHLVL to bash.

exec in bash says:
   Decrement SHLVL by 1 so a new shell started here has the same value,
   preserving the appearance.  After we do that, we need to change the
   exported environment to include the new value.  If we've already forked
   and are in a subshell, we don't want to decrement the shell level
   since we are `increasing' the level

Busybox:
$ sh -c 'echo $SHLVL; exec sh -c "echo \$SHLVL"'
2
3
$ sh -c 'echo $SHLVL; (exec sh -c "echo \$SHLVL")'
2
3

Bash:
$ bash -c 'echo $SHLVL; exec bash -c "echo \$SHLVL"'
2
2
$ bash -c 'echo $SHLVL; (exec bash -c "echo \$SHLVL")'
2
3

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the busybox-cvs mailing list