Script arg with doble quote

when i have a path like that :

/path/to/“Hello\ world”/

this string being the argument of a ruby script (the same does apply for
shell scripts) i don’t get it right but rather :

/path/to/Hello world/

the doble quotes vanished due to shell.

i get this arg by the Finder (Mac OS X)

then, i can’t change it because if the argument where single quotes
wrapped like that :

‘/path/to/“Hello\ world”/’

i get the right arg, saying :

/path/to/“Hello world”/

someone sees a workaround ?

Une bévue wrote:

someone sees a workaround ?

But you’ve just posted the solution – single quote the argument.

When you post a problem and seek a solution, please make sure to state
the
problem clearly, like this:

  1. I wanted this: ________________________

2, But instead, I got this: _________________________

  1. Here is how (2) differs from (1): _____________________

  2. Here are the reasons I can’t apply the obvious fix: _______________

Paul L. [email protected] wrote:

But you’ve just posted the solution – single quote the argument.

i can’t the double quotes are eated by the shell and if i add the single
quote, it’s to late

When you post a problem and seek a solution, please make sure to state the
problem clearly, like this:

  1. I wanted this: ________________________

transform a unix path into an url provided the path is under the apache
server root.

/path/to/“Hello\ world!”/

2, But instead, I got this: _________________________

in case the path contains double quotes, the double quotes are eated by
the shell and or finder (mac os x). then i got :

/path/to/Hello\ world!/

  1. Here is how (2) differs from (1): _____________________

the " vanished.

  1. Here are the reasons I can’t apply the obvious fix: _______________

the obvious fix being to wrapp the path with single quote like that :

‘/path/to/“Hello\ world!”/’

this would protect the double quote, unfortunately at the time i can add
single quotes (within a shell script or a ruby one) it is too late
because double quote vanished due (i believe) to the shell way of
passing arf to any kind of scripting facility (zsh, sed, ruby)…

Une bévue wrote:

/ …

this would protect the double quote, unfortunately at the time i can add
single quotes (within a shell script or a ruby one) it is too late
because double quote vanished due (i believe) to the shell way of
passing arf to any kind of scripting facility (zsh, sed, ruby)…

If I understand you correctly, you don’t have control over where the
shell
script argument comes from, and at the first opportunity, it’s already
too
late – essential data has already been lost. Yes?

Is there any way to access the original data that gets around this
problem?
Can you tell a user to act differently? You haven’t said where the
information comes from, or how it gets to your script.

Une bévue wrote:

/path/to/Hello\ world!/

  1. Here is how (2) differs from (1): _____________________

the " vanished.

Why do you need the double quotes? If it’s to pass the path back to the
shell (or other, similar place), you can put quotes around the entire
argument to the same effect.

For example:

path = ARGV[0]
system(“ls -l ‘#{ARGV[0]}’”) #Using single quotes avoids having to
escape them

Does that help?

-Justin

Collins, Justin [email protected] wrote:

Does that help?

no because the path I get is trhu another api i’m not the master of.

in fact it is my lone arg coming from Finder (Mac OS X) thru (Bog Cat a
Contextual Menu helper).

i think big cat is buggy for that point of view then, for the time being
i prevent the final user not to use double quotes in file/dir names
which pretty uncommon )))

Une bévue wrote:

someone sees a workaround ?

Just escape the double quotes the same way you escape the blank:

“Hello,\ world”

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs