I want to use yad 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
#!/bin/bash
items=`yad --list --separator='' --height=600 --multiple --column="Items" item1 item2 item3`
echo $items
IFS=' ' read -r -a ARRAY <<< $items
for item in "${ARRAY[@]}"; do
echo "$item"
done
should output
item1 item2 item3
item1
item2
item3
Instead the script only outputs:
item1 item2 item3
item1
I am using this trick 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.
Echoing $items
into a textfile and reading this textfile with cat works as expected: Replacing IFS=' ' read -r -a ADDR <<< $items
in the above script with
echo "$items" > tmpfile
IFS=' ' read -r -a ADDR <<< `cat tmpfile`
yields the expected result.
What am I missing here?