bug-bash
[Top][All Lists]
Advanced

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

Re: errexit and local variable set by failing command


From: Chet Ramey
Subject: Re: errexit and local variable set by failing command
Date: Wed, 1 Apr 2020 15:10:01 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Thunderbird/68.5.0

On 4/1/20 1:21 PM, Krystian Wojtas wrote:
> Aha, already known. Thank you for link. I'll get familiar with other cases.
> 
> I just figured out that it works as expected if local variable is firstly 
> declared and then set.

That's because the exit status of a command consisting only of assignment
statements is special-cased to be the exit status of the last command
substitution to occur while processing the assignments.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/



reply via email to

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