Applescript does not seem to properly escape strings. What am I doing wrong?
Example:
set abc to "funky-!@#'#\"chars"
display dialog abc
display dialog quoted form of abc
Expected / Desired Output:
funky-!@#'#"chars
'funky-!@#\'#"chars'
Actual Output:
funky-!@#'#"chars
'funky-!@#'\''#"chars'
As you can see, it appears that in the actual output Applescript is adding and escaping an extra '
I would be OK with the end characters being either ' or " and I would also be fine with both the single and double quotes being escaped – but it appears that only the single quotes are actually escaped.
Backslashes aren’t usually interpreted inside single quotes in shells.
However they are interpreted by echo in sh, which is the shell used by
do shell script:Unsetting
xpg_echomakes it behave like the echo in bash:Often it’s simpler to use HEREDOC redirection instead: