Hello,

$ PS4='Before: ${ set +o noglob +o xtrace; PS4="After: "; }' bash -o xtrace -o 
noglob -c '
  true; echo "$BASH_VERSION $SHELLOPTS $-"'

Gives:

Before: true
After: echo '5.4.0(7)-devel braceexpand:hashall:interactive-comments hxBc'
5.4.0(7)-devel braceexpand:hashall:interactive-comments hxBc

(same with 5.3.15(1)-release).

Upon running "true", $PS4 is expanded which runs "set +o xtrace"
in the non-subshell form of command substitution (same happens
with the ${|...} form) which should have disabled "xtrace" and
caused the subsequent "echo" commands not to be traced.

You can see "xtrace" is gone from $SHELLOPTS, but "x" is still
in $- and that echo command still traced.

"noglob" (f) itself was properly unset in both $- and $SHELLOPTS

It's good that the commands running through $PS4 expansion
themselves are not traced though that doesn't appear to be
documented (and that temporary disabling of xtrace could be at
the source of the issue here).

Expected:

Before: true
5.4.0(7)-devel braceexpand:hashall:interactive-comments hBc

(no "After" trace and "x" gone from $-).

-- 
Stephane

Reply via email to