Chet Ramey
Thu, 04 Mar 2010 19:21:59 -0800
On 3/4/10 2:36 AM, Ettelbrueck, Heiko wrote: > Important detail: The local variable is declared and defined in > the same step with "local VARNAME=$(do something)". > > Problem: The $? variable is always 0 after that statement. (If, > on the other hand, I separate the declaration and the > definition of the variable as shown in the example below, the > $? variable is really set to the exit status of the external > tool.)
The exit status is the status of the command you run: local. In the
absence of a command, when there are only assignment statements, the
exit status can be the exit status of a command substitution:
"If there is no command name, but the command contained a command
substitution, the command shall complete with the exit status of the last
command substitution performed. Otherwise, the command shall complete with
a zero exit status."
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU c...@case.edu http://cnswww.cns.cwru.edu/~chet/