[Top][All Lists]

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

Re: set -e behaviour. Seems bug. Not the subshell issue!

From: Eric Blake
Subject: Re: set -e behaviour. Seems bug. Not the subshell issue!
Date: Tue, 11 Sep 2012 06:07:42 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120828 Thunderbird/15.0

On 09/11/2012 05:51 AM, Марк Коренберг wrote:
> fun()
> {
>     echo 'Execute really bad command:'
>     /bin/false
>     echo 'should not print this'
>     return 0
> }
> if ! fun; then
>     echo 'should catch fault here'

Wrong.  '! fun' is executed in a context in which 'set -e' is ignored,
so ALL commands with 'fun' are executed without error aborts, which mean
'should not print this' MUST be printed, and 'should catch fault here'
must NOT be printed.

This behavior conforms to POSIX.

> Is any way to force "set -e" to work even in such cases?

No, it is already working as specified (just not the way you want).

> If this question asked 1000 times, why not to answer in FAQ (
> http://tiswww.case.edu/php/chet/bash/FAQ)?


Eric Blake   address@hidden    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

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