This is the mail archive of the cygwin-patches mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]