Configuration Information [Automatically generated, do not change]: Machine: x86_64 OS: linux-gnu Compiler: x86_64-pc-linux-gnu-gcc Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-pc-linux-gnu' -DCONF_VENDOR='pc' -DLOCALEDIR uname output: Linux diegom 2.6.34-gentoo-r12 #1 SMP Mon Nov 29 06:02:02 ART 2010 x86_64 Intel(R) Pentium(R) Dual CPU T2330 @ 1.60GHz GenuineIntel GNU/Linux Machine Type: x86_64-pc-linux-gnu
Bash Version: 4.1 Patch Level: 7 Release Status: release Description: It's difficult to explain. Better see below the particular case I had. I needed to assign the elements of an array to other, but with a preceding single quote. The following is a simplified (yet illustrative) example. declare -a array1=(a b c d e f) array2=() array2=( "${array1[@]/#/'}" ) AFAIK (plus the man page), the syntax of pattern substitution is ${parameter/pattern/string}, where "string" is just that, a string. I have also tried the following: array2=( "${array1[@]/#/"'"}" ) But that caused a literal preceding "'", which technically is ok. The ugly solution I had to take was a for loop. Nothing stressing but bothers. BASH shouldn't have treated specially the single quote after the slash and before the closing brace (I think). Actual Results: Nothing actually, just the PS2 wating for a closing single quote. Expected Results: 'a 'b 'c 'd 'e 'f Repeat-By: (Always Reproducible.) declare -a my_array=(a b c d e) echo "${my_array[@]/#/'}" Fix: None really, but two workarounds: 1) Using a for loop. 2) Declaring a variable, assigning it a single quote and expanding it in the "string" part of the substitution: $ q="'" $ echo "${my_array[@]/#/$q}" (Proposed by Ulrich Müller) This is discussed in Gentoo's bugzilla in bug #356403 -- Diego Augusto Molina diegoaugustomol...@gmail.com