[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: bash does filename expansion when assigning to array member in compo
From: |
Dan Douglas |
Subject: |
Re: bash does filename expansion when assigning to array member in compound form |
Date: |
Sat, 18 Aug 2012 18:15:13 -0500 |
User-agent: |
KMail/4.8.3 (Linux/3.4.6-pf+; KDE/4.8.3; x86_64; ; ) |
On Saturday, August 18, 2012 07:55:17 PM Stephane Chazelas wrote:
> 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.
>
> Just do
>
> a=("*") or a=('*') or a=(\*)
>
>
Eh yeah. At least the left side gets implicit quoting, and it correctly
disables brace expansion. In mksh compound assignment is just sugar for set -A,
so Bash isn't unique in this.
$ touch 1=a; mksh -c 'a=([123]=*); print -r "address@hidden"'
1=a
--
Dan Douglas
- bash does filename expansion when assigning to array member in compound form, Gundi Cress, 2012/08/18
- Re: bash does filename expansion when assigning to array member in compound form, Dan Douglas, 2012/08/18
- Message not available
- Re: bash does filename expansion when assigning to array member in compound form, Gundi Cress, 2012/08/20
- Re: bash does filename expansion when assigning to array member in compound form, Roman Rakus, 2012/08/20
- Re: bash does filename expansion when assigning to array member in compound form, Dan Douglas, 2012/08/20
- Re: bash does filename expansion when assigning to array member in compound form, Chet Ramey, 2012/08/22
- Re: bash does filename expansion when assigning to array member in compound form, Chet Ramey, 2012/08/24
- Re: bash does filename expansion when assigning to array member in compound form, Dan Douglas, 2012/08/29
- Re: bash does filename expansion when assigning to array member in compound form, Chet Ramey, 2012/08/29
- Re: bash does filename expansion when assigning to array member in compound form, Stephane Chazelas, 2012/08/21
- Re: bash does filename expansion when assigning to array member in compound form, Dan Douglas, 2012/08/21