|
From: | Roman Rakus |
Subject: | Re: bash does filename expansion when assigning to array member in compound form |
Date: | Mon, 20 Aug 2012 19:44:51 +0200 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120717 Thunderbird/14.0 |
On 08/20/2012 07:12 PM, Gundi Cress wrote:
And how would you achieve to fill array with all file names containing `[1]=' for example. Definitely it's good, if you want to be sure, to always quote all characters which means pathname expansion - `*', `?' and `['.Am Sat, 18 Aug 2012 19:55:17 +0100 schrieb Stephane Chazelas:2012-08-18 10:26:22 -0500, Dan Douglas:This is a feature that all shells with this style of compound assignment have in common. If no explicit subscripts are given, the text between the parentheses is processed exactly as though it were arguments to a command including brace expansion, word-splitting, and pathname expansion (and consequently, quoting is just as important). This is an important feature because it allows storing the results of a glob in an array easily. If a subscript is given explicitly, then the right-hand side of the assignment is treated exactly as an ordinary scalar assignment would be, including all analagous behaviors for `+=' and the integer attribute. $ set -x; a=( [1]=* ) + a=([1]=*)[...] Nope: ~/1$ touch '[1]=x' ~/1$ bash -c 'a=( [1]=* ); echo "address@hidden"' [1]=x ~/1$ bash -c 'a=( [1]=asd ); echo "address@hidden"' asd That's a bug though.I'm not sure if I got it right. Please correct me if I got it wrong: It is not generally a bug that Bash does filename expansion when assigning to array members in compound form. Only if explicit indices identify array members in a compound assignment there should be no filename expansion and it's a bug if Bash does so. Gundi
RR
[Prev in Thread] | Current Thread | [Next in Thread] |