help-bash
[Top][All Lists]
Advanced

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

[Help-bash] Changed Behaviour from 4.2 to 4.3


From: Deniz Adrian
Subject: [Help-bash] Changed Behaviour from 4.2 to 4.3
Date: Fri, 5 Aug 2016 16:05:56 +0200

Hey there,

I'm observing changed behaviour between 4.2 and 4.3:

> [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
> [zined bash-testing]$ ./bash4.2 test_works_in_4.2_breaks_in_4.3
> + eval test_function
> ++ test_function
> ++ set -e
> ++ false
> [zined bash-testing]$ echo $?
> 1
> [zined bash-testing]$ ./bash4.3 test_works_in_4.2_breaks_in_4.3
> + eval test_function
> ++ test_function
> ++ set -e
> ++ false
> ++ return 0
> + exit 0
> [zined bash-testing]$ echo $?
> 0
> [zined bash-testing]$

If i don't evaluate the exit code of `eval`, `-e` does it's job like a
charm:

> [zined bash-testing]$ cat test_workaround_works_in_4.2_and_4.3
> #!/bin/bash
>
> set -x
>
> function test_function
> {
>   set -e
>   false
>   return 0
> }
>
> eval test_function
> [zined bash-testing]$ ./bash4.2 test_workaround_works_in_4.2_and_4.3
> + eval test_function
> ++ test_function
> ++ set -e
> ++ false
> [zined bash-testing]$ echo $?
> 1
> [zined bash-testing]$ ./bash4.3 test_workaround_works_in_4.2_and_4.3
> + eval test_function
> ++ test_function
> ++ set -e
> ++ false
> [zined bash-testing]$ echo $?
> 1
> [zined bash-testing]$


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

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.

Is the observed behaviour change intended?


Cheers
Deniz


reply via email to

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