[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
${parameter#[:upper:]} does not work with LANG=en_US
From: |
Jim Avera |
Subject: |
${parameter#[:upper:]} does not work with LANG=en_US |
Date: |
Mon, 1 Apr 2002 12:53:56 -0800 |
Configuration Information [Automatically generated, do not change]:
Machine: i386
OS: Linux
Compiler: gcc
Compilation CFLAGS: -DHAVE_VFPRINTF -DHAVE_UNISTD_H -DHAVE_STDLIB_H
-DHAVE_LIMITS_H -DHAVE_GETGROUPS -DHAVE_RESOURCE -DHAVE_SYS_PARAM
-DVOID_SIGHANDLER -DHAVE_GETDTABLESIZE -DHAVE_BCOPY -DHAVE_GETPW_DECLS
-DHAVE_GETHOSTNAME -DHAVE_WAIT_H -DHAVE_DUP2 -DHAVE_STRERROR
-DHAVE_DIRENT_H -DHAVE_STRING_H -DHAVE_VARARGS_H -DHAVE_STRCHR
-DHAVE_DEV_FD -Di386 -DLinux -DSHELL -DHAVE_ALLOCA -DHAVE_ALLOCA_H
-O2 -m486 -fno-strength-reduce
uname output: Linux red3 2.4.2 #2 SMP Wed Apr 25 01:26:59 PDT 2001 i686 unknown
Bash Version: 1.14
Patch Level: 7
Description:
The POSIX.2 character class [:upper:] does not work in the
${param#[...]} syntax. The [:upper:] pattern does not match
an an initial upper-case letter.
Note, however, that ${param%...} *does* seem to work (see demo).
This was observed when no env vars other than PATH are set:
Repeat-By:
Run this demo script.
You can do env - PATH=/bin:/usr/bin scriptfile
to avoid influences from environment variables I didn't have.
#!/bin/bash
foo="Atail"
tr_result=`echo $foo | tr '[:upper:]' '[:lower:]'`
if test "X$tr_result" != "Xatail" ; then
echo "TEST FAILED: tr with POSIX.2 char classes"
echo "Got '$tr_result' expected 'atail'"
fi
res1="${foo#[A-Z]}"
if test "X$res1" != "Xtail" ; then
echo "TEST FAILED: \${foo#[A-Z]}"
echo "Got '$res1' expected 'tail'"
fi
res2="${foo#[:upper:]}"
### THIS ONE FAILS ###
if test "X$res2" != "Xtail" ; then
echo "TEST FAILED: \${foo#[:upper:]}"
echo "Got '$res2' expected 'tail'"
fi
res3="${foo%[a-z]}"
if test "X$res3" != "XAtai" ; then
echo "TEST FAILED: \${foo%[a-z]}"
echo "Got '$res3' expected 'Atai'"
fi
res4="${foo%[:lower:]}"
if test "X$res4" != "XAtai" ; then
echo "TEST FAILED: \${foo%[:lower:]}"
echo "Got '$res4' expected 'Atai'"
fi
#---------- end of demo script ---------
- ${parameter#[:upper:]} does not work with LANG=en_US,
Jim Avera <=