X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: No, hits=-1.5 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Message-ID: <622599.51453.qm@web30201.mail.mud.yahoo.com> Date: Wed, 9 Sep 2009 11:20:51 -0700 (PDT) From: "Ziser, Jesse" Subject: Re: syntax for Cygwin bash invoking Win apps To: cygwin AT cygwin DOT com In-Reply-To: <20090909174534.GD29151@ednor.casa.cgf.cx> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes 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 --- On Wed, 9/9/09, Christopher Faylor wrote: > From: Christopher Faylor > Subject: Re: syntax for Cygwin bash invoking Win apps > To: cygwin AT cygwin DOT com > Date: Wednesday, September 9, 2009, 12:45 PM > On Wed, Sep 09, 2009 at 12:10:44PM > -0400, Mark J. Reed wrote: > >On Wed, Sep 9, 2009 at 12:05 PM, Christopher Faylor > wrote: > >>>>>> $ cmd /c echo "\"abc\"" > >>>>>> "\"abc\"" > >>>>>> > >>>>>> # Wahhh?! > >>>>>> > >>>>>> Anyone who knows the explanation > would make me very grateful. I've tried > >>>>>> this with other Windows apps too, > and the same weirdness seems to occur. > >>> > >>>Larry Hall: > >>>>>All of the above is consistent with > bash shell quoting. > >>> > >>>No, it's really not. ??Those backslashes should > be long gone by the > >>>time cmd.exe gets its arguments, yet it echoes > them. ??It seems that > >>>the Cygwin version of bash stops short before > doing some of the work > >>>it normally does itself on other systems, > assuming the executed > >>>command will have its command line run through > the preprocessor in the > >>>Cygwin DLL. > >> > >> Actually, I'd say that was cmd doing something > funky. ??It's hard to believe > >> that bash was actually special-casing cmd.exe. > > > >I don't think it's special-casing cmd.exe.=A0 I > think some of the > >command line processing that is done by bash on Linux > has been moved > >out of bash and into the DLL command line preprocessor > on Cygwin. >=20 > Cygwin does quote individual arguments if they contain > "special" > characters like quotes or spaces when sending a > command-line to a > windows program.=A0 It's up to the windows program to > understand quoting. OK, yeah, I now see that is basically what's going on. Bash is processing = it as normal and then Cygwin is adding all kinds of quoting before invoking= the Windows executable. However, it does more than quote them (which would only bother me a little)= , because it also added backslashes in front of the quote-marks (see the fo= llowing example, which I just discovered). $ cmd /c echo '"hi"' "\"hi\"" This does appear to give the right result ("hi") after standard Windows com= mand line parsing for Windows apps I write, so I guess that's the best thin= g to do, but I don't really understand it... I mean how does Windows decide= whether a backslash is an escape or just a backslash? Well, that's not yo= ur problem, so I'll drop it. I guess my scripts are just always going to b= e a little unpredictable -- the cost of doing business with Windows users. Now, if I can just find out exactly which kinds of preprocessing steps Cygw= in apps do on their arguments when called from Windows... but I guess I can= just go through the bash manual and try each step, one at a time, to find = out. Thanks for the help, everyone. -- 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