odetinin Posted May 14, 2014 Posted May 14, 2014 I have a need to have this snippet in my bash workflow: osascript <<EOT set myString to "This\\ is\\ string" return myString EOT It breaks with error: [ERROR: alfred.workflow.action.script] Code 1: 22:23: syntax error: Expected “"” but found unknown token. (-2741) I would like the output string to look like "This\ is\ string".
Carlos-Sz Posted May 14, 2014 Posted May 14, 2014 Try this: osascript <<EOT set myString to "This\\\\ is\\\\ string" return myString EOT odetinin 1
odetinin Posted May 14, 2014 Author Posted May 14, 2014 It worked !!! Thanks a ton ! Did not realize I need to "double" escape backslashes in applescript.
Carlos-Sz Posted May 14, 2014 Posted May 14, 2014 It worked !!! Thanks a ton ! Did not realize I need to "double" escape backslashes in applescript. In fact, you don’t have to. I’m not sure why Bash (or Alfred?) is requiring it.
deanishe Posted June 7, 2014 Posted June 7, 2014 It's because of the heredoc. If you just run osascript -e 'return "This\\ is\\ a\\ string"', you only need to escape the backslashes once.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now