Max, Thanks for your reply. Yes, the double quote issue can be reproducible from command line, but not the equal sign.
Let's demonstrate the equal sign issue with a C program: #include "unistd.h" int main(int argc, char** argv) { execl("a.bat", "a.bat", "a=b"); return 0; } The intention of the program is to pass "a=b" as a single argument. However, compile and run it under cygwin, I get: $ cc -o myprog myprog.c $ ./myprog a I run the program with Visual Studio, I get "a=b". The way Windows/Unix handles parameter containing equal sign is different. IMHO, Cygwin should be the place to fill this semantic gap. Thanks, Daniel On Mon, Jan 20, 2014 at 4:30 PM, Max Polk <maxp...@gmail.com> wrote: > 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: >> a.bat: >> echo %1 >> >> Run it under cygwin: >> ./a.bat a=b >> a >> >> ./a.bat "a=b" >> a >> >> If we pass additional \" >> ./a.bat "\"a=b\"" >> "\"a >> >> There seems no way to pass a=b into bat. > > > This is how batch files work, and likely not a problem with Cygwin: > http://support.microsoft.com/kb/35938 > 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) > C:\>Argecho.bat a=b > FIRST a > SECOND b > THIRD > > 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) > C:\>Argecho.bat "a=b" > FIRST "a=b" > SECOND > THIRD > > There is a problem getting Cygwin the above test case, however. > > The test script was: > C:\>type Argecho.bat > @echo off > 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 > FIRST a > SECOND b > THIRD > > (Run from bash, same as above since bash removes the double quotes prior to > passing to program): > $ Argecho.bat "a=b" > FIRST a > SECOND b > THIRD > > (Run from bash, this is what is surprising double surrounded with single) > $ Argecho.bat '"a=b"' > FIRST "\"a > SECOND b\"" > THIRD > > It seems that only the final test case above doesn't behave as expected.