bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Return status of command substitution with $(...) "gets lost"


From: Chet Ramey
Subject: Re: Return status of command substitution with $(...) "gets lost"
Date: Thu, 04 Mar 2010 22:20:50 -0500
User-agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.1.7) Gecko/20100111 Lightning/1.0b1 Thunderbird/3.0.1

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    address@hidden    http://cnswww.cns.cwru.edu/~chet/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]