Hi,

When IFS is unset, unquoted $* undergoes word splitting as if IFS=' ',
and not the expected IFS=$' \t\n'. All the other unquoted mass
expansions ($@, array[*], array[@]) are word-split as if IFS=$'
\t\n'.For instance:

  nb_args() { echo $#; }
 
  set -- $'a\nb'
  unset IFS
 
  # Expected: 2, actual: 2
  nb_args $@
  # Expected: 2, actual: 1
  nb_args $*
 
  ar=("$@")
  # Expected: 2, actual: 2
  nb_args ${ar[*]}
  # Expected: 2, actual: 2
  nb_args ${ar[@]}

Note that this only occurs if IFS is *globally* unset. If made local and
then unset (as in f() { local IFS; unset IFS; ... }), $* is word-split
as expected.

This is a regression that appeared in 4.3 and is still present on devel
(bash-snap-20170616). A git bisect on devel shows that commit
1a81420a36fa (bash-20130125 snapshot) introduced this change. It seems
indeed that this commit is related to the handling of $* when IFS is
unset, but my knowledge of Bash's sources is too limited to tell what's
wrong with it :-)

Kevin

Reply via email to