Jump to content

Checkbox to escape backslash in {query}


Recommended Posts

This is kind of an edge case for me, but I could't find a way to solve it. Since Alfred doesn't give to option to scape backslash, I cannot parse specific Windows paths (or anything that might end with a backslash). Basically an ending backslash automatically escapes the single quote or double quote and thus breaks the syntax of any of the scripting languages allowed. I tried with Ruby's <<SOMETHING string delimiter, but the backslash, since it's not escaped, it's treated as an escape character and it's not shown.

 

Hope it makes sense

Thanks!

Ramiro

Link to comment
Share on other sites

the thing is: I need to copy huge Windows Paths I get from other colleges, and convert them into Unix paths for us the Mac boys to browse. I can't manually replace every backslash with double backslash.

It's an edge case in my case, but I don't see why not add the escape option since the backslash is such a special character in most languages.

Link to comment
Share on other sites

the thing is: I need to copy huge Windows Paths I get from other colleges, and convert them into Unix paths for us the Mac boys to browse. I can't manually replace every backslash with double backslash.

It's an edge case in my case, but I don't see why not add the escape option since the backslash is such a special character in most languages.

 

I was referring to doing it with a script, not manually.

Link to comment
Share on other sites

ahah, ok. I'm a little lost here. I found that I cannot receive the string content 100% sure, since I need to parse it in, say, Ruby, and the backslash character might escape my last single quote, and thus break the syntax. It's like chicken and egg. How can I parse the string and escape the backslash character if it breaks the syntax of the parser? :D

 

Btw, I'm into PHP, Ruby and Python, but not much sh, so there might be ways of receiving that string information and escaping it that I might not know.

Thanks

Link to comment
Share on other sites

ahah, ok. I'm a little lost here. I found that I cannot receive the string content 100% sure, since I need to parse it in, say, Ruby, and the backslash character might escape my last single quote, and thus break the syntax. It's like chicken and egg. How can I parse the string and escape the backslash character if it breaks the syntax of the parser? :D

 

Btw, I'm into PHP, Ruby and Python, but not much sh, so there might be ways of receiving that string information and escaping it that I might not know.

Thanks

 

Ah gotcha, I see what you are saying now. I'll look into this, thanks

Link to comment
Share on other sites

This is kind of an edge case for me, but I could't find a way to solve it. Since Alfred doesn't give to option to scape backslash, I cannot parse specific Windows paths (or anything that might end with a backslash). Basically an ending backslash automatically escapes the single quote or double quote and thus breaks the syntax of any of the scripting languages allowed. I tried with Ruby's <<SOMETHING string delimiter, but the backslash, since it's not escaped, it's treated as an escape character and it's not shown.

 

Hope it makes sense

Thanks!

Ramiro

 

This tiny ruby script:

 

 

x = 'c:\path1\path2\path3\file.doc'
puts x
 
Will print:
 
c:\path1\path2\path3\file.doc
 
Because single quotes (') don't honor escapes. So if you used this:
 
x = '{query}'
 
Then you will get the query without issues.
 
Be aware however that you will need to treat that string carefully. If you insert it into a double-quoted string or command string (`) then Ruby will attempt to process the slashes as escapes.
Link to comment
Share on other sites

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