Inconsistent escaping of bash commands (depends on the first command)

Eric Blake eblake@redhat.com
Thu Jul 29 21:24:00 GMT 2010


On 07/29/2010 03:13 PM, Ives van der Flaas wrote:
> After a good few hours of searching, I've distilled this down as far
> as humanly possible. The problem I'm encountering is that if I tell
> bash.exe to execute the commands in parameter (using the -c flag),
> escaping varies based on what commands I give bash.
> A more detailed example:
> 
> 1 C:\cygwin\bin>bash.exe -x -v -c "C:\\s \\"

There's your problem - you are expecting sane quoting rules from cmd.
The quoting rules for cmd are vastly different from the quoting rules
for bash itself.

Also, remember that cmd does not do globbing before invoking a command,
but neither do cygwin apps do it on entry (they expect the shell to have
already done it).  Therefore, when a cygwin app detects that it was
invoked by a non-cygwin app, cygwin must do the globbing before main();
and yes, the rules for what cygwin1.dll will try to glob depend heavily
on how much the command line argument passed by cmd looks like it might
need globbing.

You may be better off writing a shell script with the command you really
want to run, and just calling 'bash path/to/script' than trying to call
'bash -c "complicated command"' from cmd.

-- 
Eric Blake   eblake@redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://cygwin.com/pipermail/cygwin/attachments/20100729/2794f61f/attachment.sig>


More information about the Cygwin mailing list