How to Use Cancel Button in Osascript to Stop Running Script
How about this? 


It works on my 10.6 Macbook. 
It is cleaner than having to escape quotes etc...
osascript returns a status like normal unix programs.
Bash script aborts on a status 1 from osascript.
No unnecessary messages from osascript - &gt;dev/null 2&gt;&amp;1 


I don't have anything else to test it on. You may need to adjust for other versions of OSX.

#!/bin/bash

osascript &gt;/dev/null 2&gt;&amp;1 &lt;&lt;-EOF
tell application id "com.apple.systemevents"
   set myMsg to "Do you want to continue?" &amp; return &amp; return &amp; " Please wait..."
   set theResp to display dialog myMsg buttons {"Cancel", "Okay"} default button 2 
end tell

# Following is not really necessary. Cancel returns 1 and OK 0 ...
if button returned of theResp is "Cancel" then
   return 1
end if
EOF

# Check status of osascript
if [ "$?" != "0" ] ; then
   echo "User aborted. Exiting..."
   exit 1
fi

#-- other bash stuff here
echo "All good, moving on...."


HTH