[PATCH] Fix parameter passing containing quote/equal to Windows batch command

Max Polk maxpolk@gmail.com
Wed Jan 22 01:15:00 GMT 2014

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>FIRST a

(Run from bash.exe)
$ BatchTest.exe

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.

More information about the Cygwin-patches mailing list