[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
## Array expansions in scalar assignments

**From**: |
Dan Douglas |

**Subject**: |
Array expansions in scalar assignments |

**Date**: |
Mon, 2 May 2016 11:02:14 -0500 |

Hi, it looks like these expansions still aren't quite being delimited
by IFS consistently. Probably strangest of these is a4 where `$*`
doesn't agree with `${a[*]}`, and a3 vs. a4 where quoting modifies the
result. I would think bash should look like the ksh output with all
@'s space-separated and all *'s comma-separated.
This was essentially the same bug, though I didn't test typeset vs
plain assignments or quoting variations back then:
https://lists.gnu.org/archive/html/bug-bash/2013-01/msg00167.html
+smorgbox bash-build # cat ~ormaaj/doc/projects/bash/testcases/peflattening2
shopt -s extglob
{ for sh in /bin/bash?(-*) ~ormaaj/doc/programs/bash-build/bash ksh
mksh; do "$sh" /dev/fd/3; done; } 3<<\EOF
function f {
typeset -a a
a=("$@")
typeset IFS=,
typeset a1="address@hidden ${a[*]} $@ $*"
typeset address@hidden ${a[*]}\ address@hidden $* a3 a4
a3="address@hidden ${a[*]} $@ $*"
address@hidden ${a[*]}\ address@hidden $*
unset -v IFS
printf '%s\n' "${BASH_VERSION:-${KSH_VERSION}}:" "a1=$a1" "a2=$a2"
"a3=$a3" "a4=$a4"
}
echo
f a b c
# vim: ft=sh et
EOF
+smorgbox bash-build # bash ~ormaaj/doc/projects/bash/testcases/peflattening2
4.3.42(1)-release:
a1=a,b,c a,b,c a,b,c a,b,c
a2=a,b,c a,b,c a,b,c a,b,c
a3=a b c a,b,c a b c a,b,c
a4=a b c a,b,c a b c a b c
4.4.0(1)-rc2:
a1=a,b,c a,b,c a,b,c a,b,c
a2=a,b,c a,b,c a,b,c a,b,c
a3=a b c a,b,c a b c a,b,c
a4=a b c a,b,c a b c a b c
Version ABIJM 93v- 2014-12-24:
a1=a b c a,b,c a b c a,b,c
a2=a b c a,b,c a b c a,b,c
a3=a b c a,b,c a b c a,b,c
a4=a b c a,b,c a b c a,b,c
@(#)MIRBSD KSH R52 2016/04/09:
a1=a b c a,b,c a b c a,b,c
a2=a b c a,b,c a b c a,b,c
a3=a b c a,b,c a b c a,b,c
a4=a b c a,b,c a b c a,b,c

[Prev in Thread] |
**Current Thread** |
[Next in Thread] |

**Array expansions in scalar assignments**,
*Dan Douglas* **<=**