bug-bash
[Top][All Lists]
Advanced

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

bash leaves all for loop constructs when assignment w. expression fails


From: as
Subject: bash leaves all for loop constructs when assignment w. expression fails
Date: Wed, 23 Apr 2008 18:48:45 +0200

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
uname output: Linux lion 2.6.18-5-686 #1 SMP Mon Dec 24 16:41:07 UTC 2007 i686 
GNU/Linux
Machine Type: i486-pc-linux-gnu

Bash Version: 3.1
Patch Level: 17
Release Status: release

Description:
    If you have an assignment with a wrong expression, e.g. VAR=$[8#9] bash
    displays an error message and the script runs on. But if this error
    is inside a for loop - or two nested for loops - bash leaves all loops
    at once and goes to the next statement after all loops. I would expect
    bash to continue with the next statement in the loop. Or at least abandon
    the script. I do not have a problem with the error itself but with the
    handling of it in the bash.

Repeat-By:
        #!/bin/bash
        echo "Start"
        von=$[8#9]
        echo "vor verschachtelter Schleife"
        for j in 1 2; do
            echo "Start outer $i"
            for i in 1 2; do
                    echo "Start inner $i"
                    vom=$[8#9]
                    echo "OK inner $i"
            done
            echo "RC inner for: $?"
            echo "OK outer $j"
        done
        echo "RC outer for: $?"
        echo "vor einfacher Schleife"
        for i in 1 2; do
                echo "single $i"
                von=$[8#9]
                echo "OK single $i"
        done
        echo "RC single for: $?"
        echo "Ende"





reply via email to

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