script arg with doble quote

U

Une bévue

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 ?
 
U

Une bévue

Paul Lutus said:
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!/
3. Here is how (2) differs from (1): _____________________

the " vanished.
4. 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)...
 
C

Collins, Justin

------_=_NextPart_001_01C6E92A.FEC7CDF8
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
i can't the double quotes are eated by the shell and if i add the = single
quote, it's to late

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

/path/to/"Hello\ world!"/


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!/


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 =3D ARGV[0]
system("ls -l '#{ARGV[0]}'") #Using single quotes avoids having to =
escape them


Does that help?

-Justin

------_=_NextPart_001_01C6E92A.FEC7CDF8--
 
U

Une bévue

Collins said:
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?

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 )))
 
T

Timothy Hunter

Une said:
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 ?
Just escape the double quotes the same way you escape the blank:

\"Hello,\ world\"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,214
Messages
2,571,112
Members
47,705
Latest member
noname22

Latest Threads

Top