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