regression re. fd redirections in COMSUB with TIF
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
mksh |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
Original code found in /bin/zgrep on Debian Lenny.
tglase@tglase:~ $ cat reduced-testcase
exec 3>&1
echo = start one
captured=$(
exec 5>&1
(echo one-u; echo 0 >&5) | { tr u x; } >&3
)
echo "= captured<
echo
echo = start two
captured=$(
exec 5>&1
(echo two-u; echo 0 >&5) | if :; then tr u x; fi >&3
)
echo "= captured<
tglase@tglase:~ $ posh reduced-testcase
= start one
one-x
= captured<0>
= start two
two-x
= captured<0>
tglase@tglase:~ $ mksh reduced-testcase
= start one
one-x
= captured<0>
= start two
= captured<0
two-x>
tglase@tglase:~ $ mksh -o sh reduced-testcase
= start one
one-x
= captured<0>
= start two
= captured<0
two-x>
tglase@tglase:~ $ mksh -o posix reduced-testcase
= start one
one-x
= captured<0>
= start two
= captured<0
two-x>
Tracking down the changes:
tg@blau:~ $ mksh-R39c reduced-testcase
= start one
one-x
= captured<0>
= start two
two-x
= captured<0>
tg@blau:~ $ mksh-R40 reduced-testcase
= start one
one-x
= captured<0>
= start two
= captured<0
two-x>
This may or may not be related to the COMSUB rewrite.
Oh well, actually it is:
1|tg@blau:~ $ mksh-R39c tf
one() {
exec 3>&1
captured=
}
two() {
exec 3>&1
captured=
}
tg@blau:~ $ mksh-R40 tf
one() {
exec 3>&1
}
two() {
exec 3>&1
}
This definitively needs tree-dump investigation.
Further reduced:
tg@blau:~ $ mksh-R39c -c 'exec 3>&1; x=$(echo 1; if :; then echo 3; echo >&2 2; fi >&3); echo "<$x>"'
3
2
<1>
tg@blau:~ $ mksh-R40 -c 'exec 3>&1; x=$(echo 1; if :; then echo 3; echo >&2 2; fi >&3); echo "<$x>"'
2
<1
3>
Committed revision 1004EFCF98C0668 4CE3.