[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: IFS is ignored when concatenating array elements
From: |
Chet Ramey |
Subject: |
Re: IFS is ignored when concatenating array elements |
Date: |
Sat, 14 Mar 2015 18:16:19 -0400 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 |
On 3/13/15 6:15 PM, isabella parakiss wrote:
> This works as I would expect:
>
> $ arr=(a b c); IFS=+; echo "${arr[*]/a/x}"
> x+b+c
>
>
> But for some reason, this ignores IFS:
>
> $ arr=(a b c); IFS=+; arr=${arr[*]/a/x}; echo "$arr"
> x b c
Because it doesn't occur within a double-quoted string. Posix recently
(within the last few weeks) released an interpretation that extends the
double-quoted behavior of the expansion of `*' to all contexts where word
splitting does not take place:
http://austingroupbugs.net/view.php?id=888
I haven't done anything to change the bash behavior yet.
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/