Can't get array from cmd line argument bash
<p>For some reason in the code below for loop treats args as array and wc -l can count the lines correctly but I can't get the $(#args[@]) to produce the correct count</p>

<pre><code>function doSomthing() {
local i args a
args=$1;
a=("1" "2" "3" "4");
i=0
  echo wc =`wc -l &lt;&lt;&lt; "$args"`;
  for arg in $args; do
    ((i++))
    echo "$i"
  done;
  echo i = $i
  echo a = ${#a[@]}
  echo args = ${#args[@]}
  echo $args
}
</code></pre>

<p>The output of this function is</p>

<pre><code>$&gt; doSomthing $'1\n2\n3\n4'
wc =       4
1
2
3
4
i = 4
a = 4
args = 1
1 2 3 4
</code></pre>