This is the mail archive of the
mailing list for the Cygwin project.
Re: [PATCH] Fix parameter passing containing quote/equal to Windows batch command
- From: Max Polk <maxpolk at gmail dot com>
- To: cygwin-patches at cygwin dot com
- Date: Mon, 20 Jan 2014 19:30:54 -0500
- 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>
On 1/20/2014 1:02 AM, Daniel Dai wrote:
We notice one issue when running a Windows batch command inside
cygwin. Here is one example.
Simple batch file:
Run it under cygwin:
If we pass additional \"
There seems no way to pass a=b into bat.
This is how batch files work, and likely not a problem with Cygwin:
Excerpt: "it is not possible to include an equal sign as an argument to
a batch file"
Be careful to note that cmd.exe and .bat files naturally split a=b into
two arguments and strip out the equals sign:
(Run from cmd.exe)
I did notice that adding double quotes (in cmd.exe) will make will it
arrive as one argument, and note that the double quotes are still there:
(Run from cmd.exe)
There is a problem getting Cygwin the above test case, however.
The test script was:
echo FIRST %1
echo SECOND %2
echo THIRD %3
When run from Cygwin bash, and you force the double quotes by
surrounding double quotes "a=b" with single quotes '"a=b"', you seem to
get too *many* quotes in the batch file:
(Run from bash, the batch file behaves correctly as if run from cmd.exe)
$ Argecho.bat a=b
(Run from bash, same as above since bash removes the double quotes prior
to passing to program):
$ Argecho.bat "a=b"
(Run from bash, this is what is surprising double surrounded with single)
$ Argecho.bat '"a=b"'
It seems that only the final test case above doesn't behave as expected.