B20.1 sh and bash command line parsing question

Rob Tulloh rob_tulloh@dev.tivoli.com
Wed Aug 25 09:50:00 GMT 1999


Howdy,

I think I have something that shows some promise now. The rule
for cygwin runtime seems to be:

1. Enclose the entire command line in single quotes before invoking
   'sh -c' via CreateProcess().
2. Escape (with a single backslash) all embedded single quotes in
   the command line.
3. Escape nothing else

Testing with this hypothesis now and it seems to be working
so far. Thanks to Earnie Boyd for engaging me in
some conversation that led me to some hints on what might
be going on under the covers. Cheers!

Rob

Rob Tulloh wrote:
> 
> Proof that cygwin is using GetCommandLine?
> 
> i:/apps/work/cygnus/CYGWIN~1/H-I586~1/bin/sh.exe -c 'echo \\\"hi
> there\\\"'
> i:/apps/work/cygnus/CYGWIN~1/H-I586~1/bin/bash.exe -c 'echo \\\"hi
> there\\\"'
> 
> i:\>i:/apps/work/cygnus/CYGWIN~1/H-I586~1/bin/sh.exe -c 'echo \\\"hi
> there\\\"'
> 
> \"hi there\"
> 
> i:\>i:/apps/work/cygnus/CYGWIN~1/H-I586~1/bin/bash.exe -c 'echo \\\"hi
> there\\\"
> '
> \"hi there\"
> 
> There is no reason for the Microsoft runtime to grok a single quote.
> Yet,
> it seems to work. If you then use the normal rules for shell escapes,
> you
> get the desired results. Odd, but perhaps can be leveraged...
> 
> ROb

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com



More information about the Cygwin mailing list