Skip to content

Instantly share code, notes, and snippets.

@hynkle
hynkle / osascript.md
Last active December 17, 2023 11:25
Getting AppleScript to output multiple lines to shell when executed with `osascript` proved challenging.

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