bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Array name expansion in bash-4.3


From: Chet Ramey
Subject: Re: Array name expansion in bash-4.3
Date: Wed, 23 Jul 2014 10:27:50 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:24.0) Gecko/20100101 Thunderbird/24.6.0

On 7/22/14, 1:24 PM, Corentin Peuvrel wrote:
> Hello,
> 
> I think I found a bug in bash-4.3.
> 
> An example should be self-explanatory :
> 
> bash-4.2 :
> $ arr=( idx1 idx2 )
> $ i=arr[1]
> $ echo ${!i}
> idx2
> $ echo ${!i/x/X}
> idX2
> 
> bash-4.3 :
> $ arr=( idx1 idx2 )
> $ i=arr[1]
> $ echo ${!i}
> idx2
> $ echo ${!i/x/X}
> idX1
> 
> If we use pattern substitution (or removing prefix/suffix pattern, ...)
> with an expansion of an array name which contain a non zero index, it will
> still use the index 0.

Thanks for the report.  This is the result of the variable indirection
discarding the correct index.  The attached patch should fix it.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/

Attachment: indirect-array-element.patch
Description: Source code patch


reply via email to

[Prev in Thread] Current Thread [Next in Thread]