[Top][All Lists]

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

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

From: Marc Herbert
Subject: Re: Return status of command substitution with $(...) "gets lost"
Date: Wed, 10 Mar 2010 17:28:11 +0000
User-agent: Thunderbird (X11/20090825)

Chet Ramey a écrit :
> On 3/4/10 2:36 AM, Ettelbrueck, Heiko wrote:
>>         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:

I have been bitten by this a few times. Since then I never, ever write this:
  local foo=...

But always:
  local foo; foo=...

It's overkill, but simple. I tend to even forget why I am doing this,
which is nice: now I can focus on the real problems to solve.

reply via email to

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