I'm trying to add the output of a script to a CocoaDialog textbox - problem is - it's only printing the first line....
For example - Please see below:
$ cat TEST.txt
i
am
legend
$ /Applications/CocoaDialog.app/Contents/MacOS/CocoaDialog textbox --debug --text `while read line; do echo $line; done < TEST.txt` --button1 "Close"
After running this the output is just "i"
Any ideas?
Cheers
Replace `while read line; do echo $line; done < TEST.txt`
with "`while read line; do echo $line; done < TEST.txt`"
, or preferably "$(<TEST.txt)"
.
read
strips characters in IFS
from the start and end of lines. read
also interprets backslashes without -r
. echo $line
strips and collapses characters in IFS
.
$ echo ' aa a\\a'|while read l;do echo $l;done
aa a\a
$ echo ' aa a\\a'|while read l;do echo "$l";done
aa a\a
$ echo ' aa a\\a'|while read -r l;do echo "$l";done
aa a\\a
$ echo ' aa a\\a'|while IFS= read -r l;do echo "$l";done
aa a\\a