bug-bash
[Top][All Lists]
Advanced

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

Re: set -e and OR-lists


From: Chet Ramey
Subject: Re: set -e and OR-lists
Date: Fri, 23 Feb 2007 16:59:36 -0500
User-agent: Thunderbird 1.5.0.9 (Macintosh/20061207)

Johan Hovold wrote:
> Hi, 
> 
> Is the following behaviour intended or a bug in bash (3.1.17(1)-release)? The 
> command list 
> 
>   (set -e; false; echo hello)
> 
> does not print hello and has non-zero exit status. All fine. If I try to use 
> this fact to display an error message the semantics changes. The following 
> command
> 
>   (set -e; false; echo hello) || echo fail
> 
> _does_ print hello _rather_ than fail. Why is this? One could argue that the 
> first echo command is now part of an OR-list, but this on the parent-shell 
> level (where set -e has no other effects) and via the command list, and not 
> in the subshell.
> 
> A corresponding change occurs if the command list is part of an AND-list.

The subshell inherits the knowledge it's part of an AND or OR list.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                       Live Strong.  No day but today.
Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/




reply via email to

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