On 06/24/2011 03:51 AM, Harald Dunkel wrote:
> Hi folks,
>
> A colleague pointed me to this problem: If I run
>
> ( set -e; ( false; echo x ) )
>
> in bash 4.1.5, then there is no screen output, as
> expected. If I change this to
>
> ( set -e; ( false; echo x ) || echo y )
>
> then I get "x" instead of "y". How comes?
Because '(false; echo x)' is on the left hand of ||, which disables set
-e for that portion of the command line. ksh behaves the same way, so
it is not a bash bug.
> Any helpful comment would be highly appreciated.
set -e seldom does exactly what you want - even the writers of POSIX
2008 got it wrong, and here's how they corrected it:
http://austingroupbugs.net/view.php?id=52
and that's what bash 4.1 implemented.
--
Eric Blake eblake@redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
signature.asc Description: OpenPGP digital signature