Jump to content

Recommended Posts

Posted

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".

Posted

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.

  • 4 weeks later...
Posted

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.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...