title: Concatenation of AWK array variables - unexpected behaviour
body: <p>Input file</p>
  
  <pre><code>steve,apples
  steve,oranges
  john,pears
  john,oranges
  mary,bananas
  steve,plums
  mary,nactarines
  </code></pre>
  
  <p>I want to get output like this:</p>
  
  <pre><code>steve:apples,oranges,plums
  john:pears,oranges
  mary:bananas,nectarines
  </code></pre>
  
  <p>Here is the one liner I have been trying to get to work:</p>
  
  <pre><code>awk -F, '{if(a[$1])a[$1]=a[$1]","$2; else a[$1]=$2;}END{for (i in a)print i ":" a[i];}' OFS=, inputfile
  </code></pre>
  
  <p>The output it gives is </p>
  
  <pre><code>,orangesrs
  ,plumsesples
  ,nactariness
  </code></pre>
  
  <p>It would appear that the string concatenation <code>a[$1]=a[$1]","$2</code> is resulting in the original value of the array element to be overwritten to some degree. How can I carry out this concatenation correctly?</p>
  
  <p>Incidentally, I get the same results on Centos, and Mac OSX.</p>