Bug 189766 - Bug in case statement using pattern matching in function
Summary: Bug in case statement using pattern matching in function
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: bash
Version: 4
Hardware: i386
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Tim Waugh
QA Contact: Ben Levenson
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2006-04-24 14:36 UTC by Austin France
Modified: 2007-11-30 22:11 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2006-04-24 15:11:24 UTC
Type: ---
Embargoed:


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

Description Austin France 2006-04-24 14:36:31 UTC
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 14:36:31 UTC
Created attachment 128149 [details]
Test Script

Comment 2 Tim Waugh 2006-04-24 15:11:24 UTC
[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.