This is the mail archive of the
cygwin-patches
mailing list for the Cygwin project.
Re: [PATCH] Fix parameter passing containing quote/equal to Windows batch command
- From: Daniel Dai <daijyc at gmail dot com>
- To: cygwin-patches at cygwin dot com
- Date: Fri, 24 Jan 2014 15:14:30 -0800
- Subject: Re: [PATCH] Fix parameter passing containing quote/equal to Windows batch command
- Authentication-results: sourceware.org; auth=none
- References: <CABDpyCh3VMDmd4Rb64Fz-cb2HzUwtZ0cY9T3xWUC8_O-eqKO6Q at mail dot gmail dot com> <20140124203415 dot GA6857 at ednor dot casa dot cgf dot cx>
Hi, Christopher,
The current logic is: if the parameter contains quote, then put a
quote around the parameter (winf.cc:78). However, if the quote is in
the beginning/end, cygwin will still quote it, and thus double quoted
parameter (such as ""a=b"").
In the previous example, I want to pass equal sign into a bat file, I
know Windows bat will not see equal sign unless it is surrender by
quote, so I have to quote it (that's not true now with auto quote for
equal sign you just checked in). Then winf.cc:78 will detect the
quote, and put another quote around, so what Windows bat see is a
double quoted parameter. And surprisingly in this case, bat file does
not treat ""a=b"" as a single parameter, %1 becomes ""a, %2 becomes
b"". Anyway, my point for #2 is, if the parameter is quoted, it
usually means user want the executable see the parameter inside the
quote, it should be treated differently than quote in the middle of
the parameter, we shall not add another quote around it in this
scenario.
And thanks for checkin #1.
Thanks,
Daniel