Max, Yes, you are right. I did a "echo %*" mistakenly in my bat script on Windows.
In terms of consistency, this one does makes a difference (parameter contains space): int main(int argc, char** argv) { execl("a.bat", "a.bat", "a b"); return 0; } On cygwin, $1=="a b", on Windows however, I get %1==a. Cygwin quote the parameters containing space automatically. Anyway, I am not bothered by inconsistent behavior between Windows/Cygwin. What I really care about is fixing the quote issue, otherwise I have no way to pass parameter with equal sign to bat. Thanks, Daniel On Tue, Jan 21, 2014 at 5:15 PM, Max Polk <maxp...@gmail.com> wrote: > On 1/21/2014 4:27 AM, Daniel Dai wrote: >> >> 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. > > > In Visual Studio, you don't get "a=b", you get the same results, a and b are > separate arguments. > > (Run from cmd.exe window) > C:\path>BatchTest.exe > > C:\path>FIRST a > SECOND b > THIRD > > (Run from bash.exe) > $ BatchTest.exe > $ FIRST a > SECOND b > THIRD > > Source code to Visual Studio project: > > #include "stdafx.h" > #include <process.h> > > int _tmain(int argc, _TCHAR* argv[]) > { > _execl ("Argecho.bat", "Argecho.bat", "a=b", NULL); > } > > Script for Argecho.bat: > > > @echo off > echo FIRST %1 > echo SECOND %2 > echo THIRD %3 > > Cygwin looks consistent with both Visual Studio compiled app calling a batch > file and the command line calling the batch file. It looks the same both > ways. >