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