bug-bash
[Top][All Lists]
Advanced

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

Pattern replacement inconsistency


From: Bernd Eggink
Subject: Pattern replacement inconsistency
Date: Wed, 30 May 2007 11:53:59 +0200
User-agent: Thunderbird 1.5.0.8 (X11/20061025)

Configuration Information:
Machine: i686
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i686' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i686-pc-linux-gnu' -DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H -I. -I. -I./include -I./lib -O2 -march=i686 -pipe uname output: Linux Celsius 2.6.21.3 #1 SMP PREEMPT Fri May 25 10:14:50 CEST 2007 i686 GNU/Linux
Machine Type: i686-pc-linux-gnu

Bash Version: 3.2
Patch Level: 17
Release Status: release

Description:
If a is an array, ${a[*]//%pattern/replacement} and ${a[*]//#pattern/replacement} don't work. Both do nothing. The single-slash
versions ${a[*]/%pattern/replacement} and ${a[*]/#pattern/replacement} work
as expected.

One could argue about using // in this context, but anyway the behavior is
inconsistent in 2 ways:

- The double-slash versions worked in 3.1.
- The double-slash versions work in 3.2 if the pattern does _not_ start with % or #.

Repeat-By:
    x=(a1 a2 a3)
    echo ${x[*]//%/y}   # output: a1 a2 a3
    echo ${x[*]//%2/y}  # output: a1 a2 a3
    echo ${x[*]//#/y}   # output: a1 a2 a3
    echo ${x[*]//#a/y}  # output: a1 a2 a3
    echo ${x[*]//a/y}   # output: y1 y2 y3

--
Bernd Eggink
monoped@sudrala.de
http://monoped.de




reply via email to

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