Jump to content

Query Escaping in File Action Workflows


Recommended Posts

I'm trying to create a File Action workflow to open selected files in Kaleidoscope (a diff tool). There are two steps in the workflow:

  1. A File Action, named "Compare in Kaleidoscope", that accepts multiple files.
  2. A Bash script that runs "open -a Kaleidoscope {query}"

The Bash script has all six escaping checkboxes checked. There is no option to escape a single quote character, though. As a result, this breaks when comparing files that contain a single quote in the filename.

 

On Twitter, @alfredapp suggested wrapping {query} in double quotes and escaping the double quotes. This broke the workflow, I'm guessing because it looks to the Bash script that {query} is a single argument.

 

Any suggestions on how to get this to work?

Link to comment

I'm trying to create a File Action workflow to open selected files in Kaleidoscope (a diff tool). There are two steps in the workflow:

  1. A File Action, named "Compare in Kaleidoscope", that accepts multiple files.
  2. A Bash script that runs "open -a Kaleidoscope {query}"

The Bash script has all six escaping checkboxes checked. There is no option to escape a single quote character, though. As a result, this breaks when comparing files that contain a single quote in the filename.

 

On Twitter, @alfredapp suggested wrapping {query} in double quotes and escaping the double quotes. This broke the workflow, I'm guessing because it looks to the Bash script that {query} is a single argument.

 

Any suggestions on how to get this to work?

 

With multiple files, the {query} is passed in as tab separated. It's best to separate {query} into variables before using the open command, and wrap those with quotes, then pass the two separate arguments as necessary. There should be a few examples of this on the forum, maybe a user can help you out with this as I can't spot one at this point.

Link to comment

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