bug-bash
[Top][All Lists]
Advanced

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

Re: (set -u -e; trap true EXIT; echo $bad) exits 0


From: Chet Ramey
Subject: Re: (set -u -e; trap true EXIT; echo $bad) exits 0
Date: Fri, 10 Apr 2009 20:24:11 -0400
User-agent: Thunderbird 2.0.0.21 (Macintosh/20090302)

Piotr Zielinski wrote:
> Configuration Information [Automatically generated, do not change]:
> Machine: i486
> OS: linux-gnu
> Compiler: gcc
> Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i486'
> -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i486-pc-linux-gnu'
> -DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash'
> -DSHELL -DHAVE_CONFIG_H   -I.  -I../bash -I../bash/include
> -I../bash/lib   -g -O2 -Wall
> uname output: Linux pzlaptop 2.6.22-gg15-generic #1 SMP Fri Sep 26
> 12:50:35 EST 2008 i686 GNU/Linux
> Machine Type: i486-pc-linux-gnu
> 
> Bash Version: 3.2
> Patch Level: 25
> Release Status: release
> 
> Description:
>         The following command
> 
>         $ (set -u -e; trap true EXIT; echo $bad;) && echo OK
> 
>         displays
> 
>         bash: bad: unbound variable
>         OK
> 
>         I'd think it should exits with a non-zero error code and not
>         display OK.  This is exacly what happens if you remove -e.

Thanks for the report.  The problem is that bash doesn't always set
$? before testing whether or not the shell should exit because -e has
been set and an unset variable is being expanded.

Chet

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

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




reply via email to

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