title: Parsing yad Output Correctly in Bash
body: <p>I want to use <a href="http://code.google.com/p/yad/" rel="nofollow noreferrer">yad</a> to show a list of items and then execute a shell command on every item. However, yad seems to produce a separator character that does not seem to be a simple whitespace. I need help parsing its output. If the user selectes all three items, this bash script</p>
  
  <pre><code>#!/bin/bash
  items=`yad --list --separator='' --height=600 --multiple --column="Items" item1 item2 item3`
  
  echo $items
  
  IFS=' ' read -r -a ARRAY &lt;&lt;&lt; $items
  for item in "${ARRAY[@]}"; do
          echo "$item"
  done
  </code></pre>
  
  <p>should output</p>
  
  <pre><code>item1 item2 item3
  item1
  item2
  item3
  </code></pre>
  
  <p>Instead the script only outputs:</p>
  
  <pre><code>item1 item2 item3
  item1
  </code></pre>
  
  <p>I am using <a href="https://stackoverflow.com/questions/918886/split-string-based-on-delimiter-in-bash">this trick</a> to parse yad's output into an array. It used to work well with yad's predecessor zenity, but it seems to fail with yad.</p>
  
  <p>Echoing <code>$items</code> into a textfile and reading this textfile with cat works as expected: Replacing <code>IFS=' ' read -r -a ADDR &lt;&lt;&lt; $items</code> in the above script with</p>
  
  <pre><code>echo "$items" &gt; tmpfile
  IFS=' ' read -r -a ADDR &lt;&lt;&lt; `cat tmpfile`
  </code></pre>
  
  <p>yields the expected result.</p>
  
  <p>What am I missing here?</p>