On 9/1/21 2:23 PM, Robert Elz via austin-group-l at The Open Group wrote: > Date: Wed, 1 Sep 2021 19:04:12 +0100 > From: Harald van Dijk <a...@gigawatt.nl> > Message-ID: <837d3b5b-ac61-98eb-2741-d667a78e2...@gigawatt.nl> > > | Is there any statement that overrides the general definition to > | explicitly make this unspecified? If not, the general definition applies > | and $? must expand to 0 both times it appears on line 2. > > Perhaps as currently written that's correct, but if so, the standard > probably needs to be updated, as it is fairly clear that shells which > set $? as each command substitution finishes have always existed (in > fact, that might have been what the original Bourne shell did, I haven't > checked) and the standard should allow for that.
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. The SVR4.2 shell prints 1 42 1. I imagine the rest of the SVR4 line sh is the same. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRU c...@case.edu http://tiswww.cwru.edu/~chet/