Why does CYGWIN double the backslash in execvp()?
Peter Rosin
peda@lysator.liu.se
Thu Feb 26 22:34:00 GMT 2015
On 2015-02-26 21:59, A L wrote:
> Hi,
> Yesterday I asked about the double slash, but my question has got no
> attention (despite some other activity
> on the list). I deem the behavior as a bug. To make things more
> evident (that it's a bug) one can replace "DIR"
> with "ECHO" in the code I posted, and compare the outputs with and
> without BUG defined... I'd really appreciate
> if someone could take a look at it, or explain me why my expectations
> were wrong.
When you say
"/cygdrive/c/windows/system32/cmd.exe"
you tell Cygwin that you want posix semantics. Which you don't.
Try
"c:/windows/system32/cmd.exe"
or split arg 2 into two args: "DIR" and "C:\\", like so:
#include <stdio.h>
#include <unistd.h>
#define NOBUG
int main()
{
const char* args[5];
char** xargs;
args[0] = "/cygdrive/c/Windows/System32/cmd.exe";
args[1] = "/c";
args[2] = "DIR";
#ifdef NOBUG
args[3] = "C:\\";
#else
args[3] = "C:\\.";
#endif
args[4] = 0;
printf("Command = \"%s %s %s %s\"\n", args[0], args[1], args[2], args[3]);
xargs = (char**) &args;
execvp(args[0], xargs);
return 0;
}
I think that cmd.exe has a non-standard grasp of how command lines
should be handled and Cygwin cannot make exceptions for individual
applications, that would be a never-ending maze.
Cheers,
Peter
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
More information about the Cygwin
mailing list