In my shell script I need to actually echo " because echo will otherwise ignore the quotes. But " is also the escape code in AS. So how do I echo an escaped quote in my script? i.e. I want to print out
“hello there”
not just
hello there
do shell script “echo "hello there"” translates to “echo “hello there”” but the echo command will ignore these quotes because they aren’t escaped! How can I do this? Thanks for any hints.
Try using the “quoted form” property to escape your string:
set the_string to quoted form of "\"Hello there, I'm Mac\""
set echo_result to (do shell script "echo " & the_string)
display dialog echo_result buttons {"OK"} default button 1 with icon 1 giving up after 10
return {the_string:the_string, echo_result:echo_result}
-->{the_string:"'\"Hello there, I'\\''m Mac\"'", echo_result:"\"Hello there, I'm Mac\""}