[Top][All Lists]

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

Bug in ${PARAMETER//PATTERN/STRING} with extglob and Pattern *(PATTERN

From: Aribert Biel
Subject: Bug in ${PARAMETER//PATTERN/STRING} with extglob and Pattern *(PATTERN-LIST)
Date: Thu, 16 Nov 2000 12:01:32 +0100

Configuration Information [Automatically generated, do not change]:
Machine: i386
OS: linux
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i386'
-DCONF_OSTYPE='linux' -DCONF_MACHTYPE='i386-suse-uname output: Linux
server 2.2.16 #1 Mon Oct 30 11:47:05 CET 2000 i586 unknown
Machine Type: i386-suse-linux
Bash Version: 2.04
Patch Level: 0
Release Status: release
I tried to do things one normally uses awk for. But I need this string
manipulations on a boot-floppy, where not enough space is left for a
statically linked awk.
I just want to strip   *([[:alpha:]]|[:/]) 

from a variable, so I switched on "extglob":
(actually I only want to have the numbers, but the error boiled down to
the following:)
echo $temp
/dev/hda: 3907008 /dev/hdb: 9903600 /dev/sda: 2202244 total: 16012852
echo ${temp//*([[:alpha:]])}
Now the interactive shell hangs, consuming a lot of CPU Power. I must
kill the shell process to be able to proceed

cdable_vars     off
cdspell         off
checkhash       off
checkwinsize    on
cmdhist         on
dotglob         off
execfail        off
expand_aliases  on
extglob         on
histreedit      off
histappend      off
histverify      off
hostcomplete    on
huponexit       off
interactive_comments    on
lithist         off
mailwarn        off
no_empty_cmd_completion off
nocaseglob      off
nullglob        off
progcomp        on
promptvars      on
restricted_shell        off
shift_verbose   off
sourcepath      on
xpg_echo        off

The problem seems to be, that the Parameter Expansion
${PARAMETER//PATTERN/STRING} doesn't recognize the Pattern 

I conclude this from: 

echo ${temp//[[:alpha:]]}       # strips all alpha chars as expected
//: 3907008 //: 9903600 //: 2202244 : 16012852

 echo ${temp/*([[:alpha:]])}    # nothing happens
/dev/hda: 3907008 /dev/hdb: 9903600 /dev/sda: 2202244 total: 16012852

echo ${temp//*([[:alpha:]])}    # hangs forever
By the way: the following works as expected: it strips "/dev/hda1:" from
the left hand side of the parameter
echo ${temp##*([[:alpha:]]|[/:])}       # works as expected
3907008 /dev/hdb: 9903600 /dev/sda: 2202244 total: 16012852 blocks  

But nevertheless:

Thanks a lot for this great software!

I use Linux and therefor bash since two years and won´t go back to M$

Best regards

Ari Biel

reply via email to

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