[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Parameter expansion problem involving ${*#*--}
From: |
chak |
Subject: |
Parameter expansion problem involving ${*#*--} |
Date: |
Tue, 3 Oct 2000 11:15:48 +1100 |
Configuration Information [Automatically generated, do not change]:
Machine: i386
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i386'
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i386-redhat-linux-gnu'
-DCONF_VENDOR='redhat' -DSHELL -DHAVE_CONFIG_H -D_GNU_SOURCE
-D_FILE_OFFSET_BITS=64 -I. -I. -I./include -I./lib -I/usr/include -O2
-march=i386 -mcpu=i686
uname output: Linux enki 2.2.16-22 #1 Tue Aug 22 16:49:06 EDT 2000 i686 unknown
Machine Type: i386-redhat-linux-gnu
Bash Version: 2.04
Patch Level: 11
Release Status: release
Description:
Parameter expansion including pattern matching misbehaves in an
admittedly obscure case. More precisely, the expansion of
${*#*--}
returns the wrong value for certain values of $* containing more than
one occurrence of the substring `--'. The problem seems to be
confined to the special variable $* and does not occur with "normal"
(alphanumeric) variables.
Repeat-By:
The problem can be reproduced using the following shell script:
#!/bin/bash
echo 'Value of ${*}: ' ${*}
echo 'Value of ${*#*--}: ' ${*#*--}
echo 'Assigning $* to $bla'
bla="$*"
echo 'Value of ${bla}: ' ${bla}
echo 'Value of ${bla#*--}:' ${bla#*--}
Assuming that the script is stored in an executable file called
`bash-bug', upon execution of
% bash-bug -- --delete
the output is
Value of ${*}: -- --delete
Value of ${*#*--}: delete
Assigning $* to $bla
Value of ${bla}: -- --delete
Value of ${bla#*--}: --delete
Note the difference in the expansion of ${*#*--} and ${bla#*--}.
- Parameter expansion problem involving ${*#*--},
chak <=