bug-bash
[Top][All Lists]
Advanced

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

Unexpected word splitting on $* when IFS is unset


From: Kevin Brodsky
Subject: Unexpected word splitting on $* when IFS is unset
Date: Tue, 20 Jun 2017 01:13:07 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.0

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[*], address@hidden) 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 address@hidden

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

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