On Tuesday, August 21, 2012 07:24:31 AM Stephane Chazelas wrote: > 2012-08-20 19:44:51 +0200, Roman Rakus: > [...] > > And how would you achieve to fill array with all file names > > containing `[1]=' for example. > [...] > > Another interesting question is how to fill the array with all > the file names that start with a digit followed by "=". > ... > a=(@([0-9])=*); typeset -p a' > declare -a a='([0]="3=foo" [1]="4=foo" [2]="5=foo")'
Another way: IFS= glob=[123]=* typeset -a 'y=($glob)' And another: IFS= typeset -a "a=($(printf '%q ' [123]=*))" Or set -A if available. > > Definitely it's good, if you want to be sure, to always quote all > > characters which means pathname expansion - `*', `?' and `['. > [...] > > Yes, the problem here is that "[" is overloaded in a conflicting > manner as a globbing operator and that poorly designed special > type of array assignment. Indeed, but you were right in calling a bug. Matching weird filenames is an odd corner-case for which there are work-arounds. The current behavior doesn't make sense. Still, a variable/function attribute for disabling pathname expansion in a controled manner would be useful given that having to manage the state of set -f mostly precludes its use. -- Dan Douglas