[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: (set -u -e; trap true EXIT; echo $bad) exits 0
From: |
Piotr Zielinski |
Subject: |
Re: (set -u -e; trap true EXIT; echo $bad) exits 0 |
Date: |
Thu, 21 May 2009 22:37:41 +0100 |
2009/4/11 Chet Ramey <chet.ramey@case.edu>:
> 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.
Thanks for the reply. Does it mean it is a bug or a feature?
Piotr
> 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/
>
- Re: (set -u -e; trap true EXIT; echo $bad) exits 0,
Piotr Zielinski <=