title: Surprising array expansion behaviour
body: <p>I've been surprised with the line marked <code>(!!)</code> in the following example:</p>
  
  <pre><code>log1 () { echo $@; }
  log2 () { echo "$@"; }
  
  X=(a b)
  IFS='|'
  
  echo ${X[@]}   # prints a b
  echo "${X[@]}" # prints a b
  echo ${X[*]}   # prints a b
  echo "${X[*]}" # prints a|b
  echo "---"
  log1 ${X[@]}   # prints a b
  log1 "${X[@]}" # prints a b
  log1 ${X[*]}   # prints a b
  log1 "${X[*]}" # prints a b (!!)
  echo "---"
  log2 ${X[@]}   # prints a b
  log2 "${X[@]}" # prints a b
  log2 ${X[*]}   # prints a b
  log2 "${X[*]}" # prints a|b
  </code></pre>
  
  <p>Here is my understanding of the behavior:</p>
  
  <ul>
  <li><code>${X[*]}</code> and <code>${X[@]}</code> both expand to <code>a b</code></li>
  <li><code>"${X[*]}"</code> expands to <code>"a|b"</code></li>
  <li><code>"${X[@]}"</code> expands to <code>"a" "b"</code></li>
  <li><code>$*</code> and <code>$@</code> have the same behavior as <code>${X[*]}</code> and <code>${X[@]}</code>, except for their content being the parameters of the program or function</li>
  </ul>
  
  <p>This seems to be confirmed by the <a href="http://www.gnu.org/software/bash/manual/bashref.html#Arrays">bash manual</a>.</p>
  
  <p>In the line <code>log1 "${X[*]}"</code>, I therefore expect the quoted expression to expand to "a|b", then to be passed to the log1 function. The function has a single string parameter which it displays. Why does something else happen?</p>
  
  <p>It'd be cool if your answers were backed by manual/standard references!</p>