This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: Why does CYGWIN double the backslash in execvp()?
- From: Peter Rosin <peda at lysator dot liu dot se>
- To: cygwin at cygwin dot com
- Date: Thu, 26 Feb 2015 22:42:19 +0100
- Subject: Re: Why does CYGWIN double the backslash in execvp()?
- Authentication-results: sourceware.org; auth=none
- References: <CAKVG1_rma3GmO9JDbB0qCE_m0wwYm3vT5+QbxYhchrMLrkORDQ at mail dot gmail dot com> <CAKVG1_oTsxvqFpjZ2Kbn5fuuU9ryotHVGYB_0ymhFu5Wh5cm0g at mail dot gmail dot com>
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