bug-bash
[Top][All Lists]
Advanced

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

Re: errexit inconsistent behaviour with pipelines


From: Chet Ramey
Subject: Re: errexit inconsistent behaviour with pipelines
Date: Mon, 06 Oct 2008 09:22:30 -0400
User-agent: Thunderbird 2.0.0.17 (Macintosh/20080914)

Marcin Owsiany wrote:

> I expected that if a simple pipeline failure causes the shell to exit, and a 
> simple for loop failure causes it to exit, then a failure in their 
> combination would also cause an exit. However it is not so.

You've found a probable bug, but it's not where you think.  Each element
of a pipeline is run in a separate execution environment and a separate
process.  Even if the child process inherits the errexit flag, the fact
that false returns failure should not affect the parent shell: a pipeline
is not a simple command.  You can see this by adding another process to
the pipeline:

set -e
true | false | echo final
echo after

In all cases, `final' and `after' are both displayed.

This bug only occurs when errexit is enabled and the final element of a
pipeline is a simple command that returns a non-zero exit status.  I will
devise a fix for the next bash release.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer

Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/




reply via email to

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