This repository was archived by the owner on Jun 16, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 159
.sh.subshell is unset in PS4 #1092
Copy link
Copy link
Open
Labels
Description
Description of problem:
I like to track the level of non-forking subshells (${.sh.subshell}
) in xtrace
output, so I make it part of the PS4
prompt. However, on the current development version, .sh.subshell appears unset in the main shell environment -- but only in PS4
(that is, something like echo ${.sh.subshell}
outputs 0 as expected).
Ksh version:
Version A 2017.0.0-devel-2141-g1b6198b
How reproducible:
Always
Steps to reproduce:
build/src/cmd/ksh93/ksh -u -c \
'PS4="\${.sh.subshell:+S\${.sh.subshell},}$PS4";
set -x; echo one; echo $(echo two); echo `echo $(echo three)`'
Actual results:
build/src/cmd/ksh93/ksh: .sh.subshell: parameter not set
${.sh.subshell:+S${.sh.subshell},}+ echo one
one
S1,+ echo two
+ echo two
two
S1,+ echo three
+ echo three
+ echo three
three
Expected results:
S0,+ echo one
one
S1,+ echo two
S0,+ echo two
two
S2,+ echo three
S1,+ echo three
S0,+ echo three
three
Additional info:
Note also that the result of the ${.sh.subshell:+S\${.sh.subshell},}
expansion is corrupted on the first expansion: it should not be erroring out on account of the -u
(a.k.a. -o nounset
) option.