bug-bash
[Top][All Lists]
Advanced

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

IFS is ignored when concatenating array elements


From: isabella parakiss
Subject: IFS is ignored when concatenating array elements
Date: Fri, 13 Mar 2015 23:15:43 +0100

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




Here is the behaviour of other shells that allow that kind of syntax:

   input: arr=(a b c); IFS=+; echo "${arr[*]/a/x}"
=======================
    bash: x+b+c
     ksh: x+b+c
    yash: x+b+c
     zsh: x+b+c

   input: arr=(a b c); IFS=+; arr=${arr[*]/a/x}; echo "$arr"
=======================
    bash: x b c
     ksh: x+b+c
    yash: x+b+c
     zsh: x+b+c



reply via email to

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