bug-bash
[Top][All Lists]
Advanced

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

Recent bug in pattern matching in a case statement


From: Dave Hines
Subject: Recent bug in pattern matching in a case statement
Date: Tue, 15 Oct 2002 16:30:27 +0100
User-agent: Mutt/1.3.28i

Configuration Information [Automatically generated, do not change]:
Machine: i686
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i686' 
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i686-pc-linux-gnu' 
-DCONF_VENDOR='pc' -DSHELL -DHAVE_CONFIG_H  -I.  -I. -I./include -I./lib  -g -O2
uname output: Linux lively 2.4.18-3 #1 Thu Apr 18 07:37:53 EDT 2002 i686 unknown
Machine Type: i686-pc-linux-gnu

Bash Version: 2.05b
Patch Level: 0
Release Status: release

Description:
        There is a problem with pattern matching in case statements.
        When using a case statement inside a for loop, the pattern
        *[A-Z]* incorrectly matches a string of all lower case letters
        after the first time around the loop.

        The problem is best illustrated by the script in the Repeat-by
        section. The problem appears to have been introduced between
        versions 2.05.0(1)-release & 2.05a.0(1)-release; see the following
        runs on two different systems...

        $ bash --version
        GNU bash, version 2.05.0(1)-release (i386-suse-linux)
        $ sh bug a b C D
        testing a: Catch-all reached
        testing b: Catch-all reached
        testing C: 'C' matches *[A-Z]*
        testing D: 'D' matches *[A-Z]*

        $ bash --version
        GNU bash, version 2.05a.0(1)-release (i686-pc-linux-gnu)
        $ sh bug a b C D
        testing a: Catch-all reached
        testing b: 'b' matches *[A-Z]*
        testing C: 'C' matches *[A-Z]*
        testing D: 'D' matches *[A-Z]*


Repeat-By:
        Run this script with arguments as follows:

                sh bug a b C D

        The script is:

        ###################### Start of "bug" script
        #!/bin/sh


        for file in $@; do
            echo -n "testing $file: "
            case "$file" in
                *[A-Z]*)
                    echo "'$file' matches "'*[A-Z]*'
                    ;;


                *)  echo Catch-all reached
                    ;;
            esac
        done
        ###################### End of "bug" script


Fix:
        Revert to an earlier version of bash.




reply via email to

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