"Chet Ramey via austin-group-l at The Open Group" <austin-group-l@opengroup.org> wrote:
> Given the following: > > (exit 42) > a=$? b=`false` b=$? > > echo $? $a $b > > Bash prints 1 42 1. > > The original (v7) bourne shell and the rest of the research line through v9 > prints 1 1 (b is set to the empty string). That implies that it executes > the assignment statements in reverse order, in addition to carrying $? > through the sequence of assignments. You are right, the original Bourne Shell for unknown reasons did evaluate a series of shell variable assignments in reverse order. That was changed in ksh88 and in bosh. > The SVR4.2 shell prints 1 42 1. I imagine the rest of the SVR4 line sh is > the same. Something called SVR4.2 does not really exist. It was a minor change compared to SvR4 announced by Novell short before they sold the Copyright to SCO. I know of no customers for SVR4.2... even SCO seems to only used it internally in their project Monterey that was abandoned by IBM. There have been major changes in the Bourne Shell for SvR4, but the $? was not touched. So you are mistaken. The important thing to know here is that the Bourne Shell has some checkpoints that update the intermediate value of $?. Since that changed in ksh88 and since POSIX requires a different behavior compared to the Bourne Shell, I modified one checkpoint in bosh to let it match POSIX. (exit 42); a=$? b=`false` b=$?; echo $? $a $b prints 1 42 42 in bosh and 1 1 in the SvR4 Bourne Shell. Jörg -- EMail:jo...@schily.net Jörg Schilling D-13353 Berlin Blog: http://schily.blogspot.com/ URL: http://cdrecord.org/private/ http://sourceforge.net/projects/schilytools/files/