[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: |
Wed, 29 Aug 2012 02:03:51 -0500 |
User-agent: |
KMail/4.8.3 (Linux/3.4.6-pf+; KDE/4.8.3; x86_64; ; ) |
On Friday, August 24, 2012 09:38:44 AM you wrote:
> On 8/22/12 8:58 PM, Chet Ramey wrote:
>
> > Then how about this: words inside a compound assignment statement that are
> > recognized as assignment statements ([1]=foo) are expanded like assignment
> > statements (no brace expansion, globbing, or word splitting). Other words
> > undergo all the expansions.
That's pretty much what I had in mind. I assumed this was how Bash handled
pathname expansion until seeing Stephane's exception.
> >
> > That means you can do things like
> >
> > [{0,1,2,3}]=foo
> >
> > to set the first four elements to the same value
>
> Or should these be marked as assignment statements after brace expansion,
> with the appropriate expansions performed? It can be complicated to
> suppress brace expansion on the RHS after allowing it on the LHS.
>
> Chet
>
I can't think of any problems with either offhand. Even disabling brace
expansion entirely for words recognized as assignments wouldn't be too bad.
But it could be a nice shortcut. Current methods I could think of using brace
expansion are ugly:
$ declare -a 'a+=(['{0..3}']=foo)' b[{0..3}]=foo c=( [{0..3}]=foo )
$ declare -a "c=(${c[*]})"
$ declare -p a b c
declare -a a='([0]="foo" [1]="foo" [2]="foo" [3]="foo")'
...
--
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 <=
- 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