[Top][All Lists]

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

Declaring a local variable circumvents "-e"

From: Björn Augustsson
Subject: Declaring a local variable circumvents "-e"
Date: Wed, 24 Sep 2008 21:01:57 +0200

Configuration Information [Automatically generated, do not change]:
Machine: i386
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i386'
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i386-redhat-linux-gnu'
-DCONF_VENDOR='redhat' -DLOCALEDIR='/usr/share/locale'
-DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H   -I.  -I. -I./include
-g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector
--param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic
uname output: Linux blahonga #1 SMP Mon Aug 4
14:20:24 EDT 2008 i686 i686 i386 GNU/Linux
Machine Type: i386-redhat-linux-gnu

Bash Version: 3.2
Patch Level: 33
Release Status: release


        The test case below is pretty self-explanatory.
        The assignment in fun_bad() doesn't exit the shell,
        despite the "set -e".

        This is the version in Fedora 8.
        Also happens on
        * Bash Version: 3.1 Patch Level: 17 (Ubuntu Dapper)
        * Bash Version: 3.2 Patch Level: 0 (from ftp.gnu.org))



set -e

fun_bad() {
        local bah=$( false )

fun_good() {
        local bah
        bah=$( false )

echo "start"

echo "FAIL"
echo "(Does not get here.)"


        I haven't written a fix.

        A workaround is detailed in the test case. In short, if you declare
        variable on one line, and assign it on the next, it works as expected.


reply via email to

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