odetinin Posted May 14, 2014 Share 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". Link to comment Share on other sites More sharing options...
Carlos-Sz Posted May 14, 2014 Share Posted May 14, 2014 Try this: osascript <<EOT set myString to "This\\\\ is\\\\ string" return myString EOT odetinin 1 Link to comment Share on other sites More sharing options...
odetinin Posted May 14, 2014 Author Share Posted May 14, 2014 It worked !!! Thanks a ton ! Did not realize I need to "double" escape backslashes in applescript. Link to comment Share on other sites More sharing options...
Carlos-Sz Posted May 14, 2014 Share 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. Link to comment Share on other sites More sharing options...
deanishe Posted June 7, 2014 Share 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. Link to comment Share on other sites More sharing options...
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