This is the mail archive of the
cygwin-patches
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: Tue, 21 Jan 2014 20:15:11 -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> <52DDBFBE dot 2010800 at gmail dot com> <CABDpyChNbxjLZdHZBY_Fbq01pQM8wM5Cgmm4DcZiu7xOp=bu7Q at mail dot gmail dot com>
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.