X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: No, hits=1.1 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org MIME-Version: 1.0 In-Reply-To: <4C51F0AD.9080605@redhat.com> References: <4C51F0AD DOT 9080605 AT redhat DOT com> From: Ives van der Flaas Date: Thu, 29 Jul 2010 23:42:10 +0200 Message-ID: Subject: Re: Inconsistent escaping of bash commands (depends on the first command) To: cygwin AT cygwin DOT com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com 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 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). =C2=A0Therefore, 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 =C2=A0 eblake AT redhat DOT com =C2=A0 =C2=A0+1-801-349-2682 > Libvirt virtualization library http://libvirt.org > > --=20 Ives van der Flaas Wijntuinstraat 10 2330 Merksplas =E2=98=8E 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