[Top][All Lists]

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

Re: [Help-bash] Changed Behaviour from 4.2 to 4.3

From: Chet Ramey
Subject: Re: [Help-bash] Changed Behaviour from 4.2 to 4.3
Date: Fri, 5 Aug 2016 11:28:31 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0) Gecko/20100101 Thunderbird/45.2.0

On 8/5/16 10:05 AM, Deniz Adrian wrote:
> Hey there,
> I'm observing changed behaviour between 4.2 and 4.3:

[set -e not exiting shell if failing command is an if statement test]

>> [zined bash-testing]$ cat test_works_in_4.2_breaks_in_4.3
>> #!/bin/bash
>> set -x
>> function test_function
>> {
>>   set -e
>>   false
>>   return 0
>> }
>> if eval test_function; then
>>   exit 0
>> else
>>   exit 1
>> fi
> Using the git mirror at git://git.savannah.gnu.org/bash.git, I've bisected
> a bit and narrowed the change down to
> http://git.savannah.gnu.org/cgit/bash.git/commit/?id=ac50fbac377e32b98d2de396f016ea81e8ee9961

That's the commit for the bash-4.3 distribution.

> My gut feeling is that it's one of:
> +a.  Only Posix-mode shells should exit on an assignment failure in the
> +    temporary environment preceding a special builtin.  This is how it's
> been
> +    documented.
> +
> +b.  Fixed a bug that caused a failed special builtin to not exit a
> posix-mode
> +    shell if the failing builtin was on the LHS of a && or ||.
> causing the change.

It's not.

> Is the observed behaviour change intended?

Yes.  This change was the result of a change to the Posix description of
the `set -e' behavior: http://austingroupbugs.net/view.php?id=52 .  This
followed an extensive discussion of the desired behavior and how the
previous Posix revision was not consistent with historical sh behavior.

The relevant portion is

      2) The -e setting shall be ignored when executing the compound
          list following the while, until, if, or elif reserved word,
          a pipeline beginning with the ! reserved word, or any
          command of an AND-OR list other than the last.


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

reply via email to

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