title: Word splitting in Bash with IFS set to a non-whitespace character
body: <p>I'm going through a Bash <a href="http://mywiki.wooledge.org/WordSplitting" rel="nofollow noreferrer">tutorial</a>, and specifically the subject of word splitting.</p>
  
  <p>This script, called "args", helps demonstrate word splitting examples:</p>
  
  <pre><code>#!/usr/bin/env bash
  printf "%d args:" $#
  printf " &lt;%s&gt;" "$@"
  echo
  </code></pre>
  
  <p>An example:</p>
  
  <pre><code>$ ./args hello world, here is "a string of text!"
  5 args: &lt;hello&gt; &lt;world,&gt; &lt;here&gt; &lt;is&gt; &lt;a string of text!&gt;
  </code></pre>
  
  <p>So far so good. I understand how this works.</p>
  
  <p>However, when I replace IFS with a non-whitespace character, say <code>:</code>, the script does not perform word splitting if I pass the string directly as an argument.</p>
  
  <pre><code>$ ./args one:two:three
  1 args: &lt;one:two:three&gt;
  </code></pre>
  
  <p>However, the script <em>does</em> perform word splitting on the same string if I (1) assign the string to a variable, and then (2) pass the string to the script via parameter expansion.</p>
  
  <pre><code>$ IFS=:
  $ variable="one:two:three"
  $ ./args $variable
  3 args: &lt;one&gt; &lt;two&gt; &lt;three&gt;
  </code></pre>
  
  <p>Why? Specifically, why does passing the string as an argument undergo word splitting when IFS is unset and the delimiters are whitespace characters, but not when IFS is set to non-whitespace characters?</p>
  
  <p>When I use <code>read</code> instead of this script, the same string also undergoes word splitting as expected.</p>
  
  <pre><code>$ IFS=:
  $ read a b c
  one:two:three
  $ echo $a $b $c
  one two three
  </code></pre>