Run AppleScript from bash script
The argument for osascript -e can contain newlines:

osascript -e 'set x to "a"
say x'


You can also specify multiple -e arguments:

osascript -e 'set x to "a"' -e 'say x'


Or if you use a heredoc, bash interprets three characters (\, $, and `) between &lt;&lt;END and END but no characters between &lt;&lt;'END' and END.

osascript &lt;&lt;'END'
set x to "a"
say x
END


Edit:

Since osascript can operate with a heredoc (ie take input from /dev/stdin) then one can just write the script as a whole file and prepend with the correct shebang line:

#!/usr/bin/env osascript

set x to "a"
say x


This also allows you to save your apple script as a actual program in ~/Applications/.app using the following procedure (changing  for your script's name):

mkdir -p ~/Applications/&lt;APP_NAME&gt;.app/Contents/MacOS
touch ~/Applications/&lt;APP_NAME&gt;.app/Contents/MacOS/&lt;APP_NAME&gt;
open -A TextEdit ~/Applications/&lt;APP_NAME&gt;.app/Contents/MacOS/&lt;APP_NAME&gt;


Ensure that both the script file in .../MacOS/ and the  matches