Bug 189766 - Bug in case statement using pattern matching in function
Bug in case statement using pattern matching in function
Status: CLOSED NOTABUG
Product: Fedora
Classification: Fedora
Component: bash (Show other bugs)
4
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Tim Waugh
Ben Levenson
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2006-04-24 10:36 EDT by Austin France
Modified: 2007-11-30 17:11 EST (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2006-04-24 11:11:24 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Test Script (291 bytes, text/plain)
2006-04-24 10:36 EDT, Austin France
no flags Details

  None (edit)
Description Austin France 2006-04-24 10:36:31 EDT
Description of problem:

Bash behaving unexpecadly in a case statement.  The following test script 
demonstrates:

is_syslib()
{
        case $1 in
        L[a-z]*) echo "[$1] Begins with L then lower case" ; return 2 ;;
        [A-Z]*)  echo "[$1] Begins with uppercase letter" ; return 0 ;;
        *)       echo "[$1] is probably lowercase" ; return 1 ;;
        esac
}

is_syslib DEF
is_syslib ad
is_syslib in
is_syslib mx
is_syslib sq

Version-Release number of selected component (if applicable):

[root@spindhella ~]# bash --version
GNU bash, version 3.00.16(1)-release (i386-redhat-linux-gnu)
Copyright (C) 2004 Free Software Foundation, Inc.

How reproducible:

100% reproducable.

Steps to Reproduce:
1. Place the example code above into /tmp/test_bash_bug
2. bash /tmp/test_bash_bug
  
Actual results:

[root@spindhella ~]# bash /tmp/tstit
[DEF] Begins with uppercase letter
[ad] is probably lowercase
[in] Begins with uppercase letter
[mx] Begins with uppercase letter
[sq] Begins with uppercase letter

Expected results:

[root@spindhella ~]# ksh /tmp/tstit    # Korn shell does not exhibit this bug
[DEF] Begins with uppercase letter
[ad] is probably lowercase
[in] is probably lowercase
[mx] is probably lowercase
[sq] is probably lowercase

Additional info:

The bug also appears in 2.05a.0 version of bash on RH 7.3

  # bash --version
  GNU bash, version 2.05a.0(1)-release (i686-pc-linux-gnu)
  Copyright 2001 Free Software Foundation, Inc.

Both the AT&T ksh (sh (AT&T Labs Research) 1993-12-28 q) and pdksh produce the 
expected output.

On HPUX 10.20: sh, ksh and bash v 2.04.0 produce the expected output.
Comment 1 Austin France 2006-04-24 10:36:31 EDT
Created attachment 128149 [details]
Test Script
Comment 2 Tim Waugh 2006-04-24 11:11:24 EDT
[A-Z] only means 'upper case letters' in the C locale.  In all other locales, it
means A through to Z (as you would see list in dictionary or a book's index).

The glob for 'any upper case letter' is '[[:upper:]]'.  See the 'Pattern
Matching' section of 'Pathname Expansion' in the bash man page.

Note You need to log in before you can comment on or make changes to this bug.