又一个 ksh 的 bug

见鬼的事怎么总是我碰上。

$ 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

  1. Execute a function or a clause in background, and
  2. A subshell is invoked between the background execution and the "wait", and
  3. 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

  1. wayne, on Nov 10, 2009 at 12:28am, said:

    bug全让你碰上了。。。

Leave a Comment?


« Review  —  迅速步入中年人行列 »

Tags

Blogroll

Fairy World | STUPiD | 阅微草堂 | ShelleX | 流浪五天