I wanted to output a list of single-line strings, each item separated by a newline. I couldn't find a way to do that without combining them all into a single string. Fine.
Reasonable attempt:
osascript -e '
set myList to {"foo", "bar", "baz"}
set myString to ""
repeat with myItem in myList
set myString to myString & myItem & return
end repeat
return myString
'
No dice. That outputs:
baz
Finally got it working with:
osascript -e '
set myList to {"foo", "bar", "baz"}
set myString to "" as text
repeat with myItem in myList
set myString to myString & myItem & linefeed
end repeat
return myString
'
Difference #1: putting as text
after the empty string.
Difference #2: using linefeed
rather than return
for the newline.
Which outputs the expected:
foo
bar
baz
Thank you for posting this script, really helped me sorting out mine ;)