见鬼的事怎么总是我碰上。
$ cat kshbug
{ return 0; } &
evil=$(/bin/true) # XXX: works fine without this line
wait $!
echo $?
$ ksh kshbug
127
$ ksh --version
version sh (AT&T Labs Research) 1993-12-28 r
The correct return code should be 0. Without the line of "eval=$(bin/true)"
everything works fine. The problem happens only when
- Execute a function or a clause in background, and
- A subshell is invoked between the background execution and the "wait", and
- An external command is executed in the subshell
I googled for a while, there's no ksh bug report so far, workaround could be use output text for return code check instead. Note there's a similar report for ksh on solaris but it's not the identical issue.
Pdksh (public domain ksh) doesn't have the problem. (See another bug.)
Update: this issue doesn't happen on Ubuntu ksh version "sh (AT&T Research) 93s+ 2008-01-31".
1 Comments so far
wayne, on Nov 10, 2009 at 12:28am, said:
bug全让你碰上了。。。