bug-bash
[Top][All Lists]
Advanced

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

Re: -e doesn't work in subshells


From: Chet Ramey
Subject: Re: -e doesn't work in subshells
Date: Mon, 22 Jan 2001 11:15:21 -0500

> On Monday, January 22, 2001 10:31:40 -0500, Chet Ramey 
> <chet@nike.INS.CWRU.Edu> wrote:
> +-----
> | >   "set -e" does not abort the entire script when used inside a
> | >   parenthesized subshell; it only aborts the subshell.
> |
> | It's not supposed to.  POSIX.2 says that `set -e' causes the shell to exit
> | only if a simple command fails under certain circumstances (enumerated in
> | the bash man page).  A parenthesized subshell is not a simple command.
> +--->8
> 
> But in fact, no shell other than bash that I can find restricts -e to that 
> subset

You should have checked ksh93, the other shell which claims POSIX 
compliance:

nike.ins.cwru.edu(2)$ cat x5
        trap 'echo Congratulations, your shell is not buggy' 0
        set -e
        (false; echo you will not see this)
        trap 0
        echo You have the bash -e bug.
        exit 1
nike.ins.cwru.edu(2)$ ksh93 ./x5
You have the bash -e bug.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
( ``Discere est Dolere'' -- chet)

Chet Ramey, CWRU    chet@po.CWRU.Edu    http://cnswww.cns.cwru.edu/~chet/



reply via email to

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