This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


I'm pretty sure the problem doesn't lie with cmd.exe, since I'm
spawning the bash thread using the win32 CreateProcess function (the
cmd.exe part was just the simplest example I could think of that
reproduced the problem).

I'm already putting as much as possible in a bash script (I'm
currently in escaping hell...), but that's not really an option since
I don't get to choose what input I'm receiving. I guess I could write
to a temporary .sh file and then feed bash that file, but it's not
what I would call ideal.

Thanks,
Ives

On Thu, Jul 29, 2010 at 11:20 PM, Eric Blake <eblake@redhat.com> wrote:
> 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
>
>



-- 
Ives van der Flaas
Wijntuinstraat 10
2330 Merksplas
â 0499/31.54.37
www.GoodSoft.be

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]