un-nice things in “set -x”
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
mksh |
Fix Released
|
Medium
|
Unassigned | ||
PLD Linux |
Confirmed
|
Undecided
|
Unassigned |
Bug Description
One:
tg@blau:~ $ mksh-R41c -xc $'cat <<"EOF"
+ cat
+ <<"EOF"
foo
tg@blau:~ $ mksh -xc $'cat <<"EOF"
+ <<"EOF"cat
foo
Problem: no whitespace after here document marker.
Two:
tg@blau:~ $ mksh -xc 'foo=$(bash --version 2>&1 | head -1); echo "=$foo="'
+ + head -1
+ foo='+ + 2>&1 bash --version'
+ echo '=+ + 2>&1 bash --version='
=+ + 2>&1 bash --version=
tg@blau:~ $ mksh-R41c -xc 'foo=$(bash --version 2>&1 | head -1); echo "=$foo="'
+ bash --version
+ head -1
+ 2>&1
+ foo=GNU bash, version 2.05b.0(1)-release (i386-ecce-
+ echo =GNU bash, version 2.05b.0(1)-release (i386-ecce-
=GNU bash, version 2.05b.0(1)-release (i386-ecce-
tg@blau:~ $ mksh -xc 'foo=$(bash --version 2>&1 | head -1); echo "=$foo="'
+ + head -1
+ foo='+ + 2>&1 bash --version'
+ echo '=+ + 2>&1 bash --version='
=+ + 2>&1 bash --version=
Questionable: redirection in effect while printing trace.
Maybe not so nice: PS4 shown twice (what happens with subsequent things?)
Given: stderr redirections/
But maybe we can do better? Something like a trace fd?
tg@blau:~ $ mksh-R41c -xc 'foo=$((echo foo; bash --version) 2>&1 | head -1); echo "=$foo="'
+ 2>&1
+ head -1
+ foo=+ echo foo
+ echo =+ echo foo=
=+ echo foo=
tg@blau:~ $ mksh -xc 'foo=$((echo foo; bash --version) 2>&1 | head -1); echo "=$foo="'
+ + head -1
+ foo='+ 2>&1 + echo foo'
+ echo '=+ 2>&1 + echo foo='
=+ 2>&1 + echo foo=
This clearly shows that having the redirection in effect is not a new thing,
it just affects more cases now. (The “+ 2>&1 +” is also a cosmetic.)
Maybe some sort of buffering or pre-preparing the output? Have to look at this again.
Thanks to arekm from PLD Linux for reporting these issues.
affects: | mksh → pld-linux |
Changed in pld-linux: | |
status: | New → Confirmed |
affects: | pld-linux → mksh |
Changed in mksh: | |
status: | Confirmed → New |
Changed in pld-linux: | |
status: | New → Confirmed |
Changed in mksh: | |
status: | Fix Committed → Fix Released |
Nice DoS:
{{{
tg@blau:~ $ PS4='$(echo foo) + '
tg@blau:~ $ set -x
^C/bin/mksh: can't fork - try again
+ echo foo
foo + echo foo
[…]
}}}
Solution: disable Flag(XTRACE) while expanding PS4, hard (possibly make Flag(XTRACE) a bitfield).