Why does CYGWIN double the backslash in execvp()?

A L al20878@gmail.com
Fri Feb 27 18:03:00 GMT 2015


> What I think happens is that since you
> specify a full posix path to cmd, you get posix semantics and none of
> the Windows compatibilty crap kicks in.

that may be, if your very own suggestion to split the last arg in two worked
just fine with the full posix path, i.e. while this set of arguments:

"/cygdrive/c/windows/system32/cmd.exe" "/c" "DIR C:\\"

does not work correctly (supposedly because of invoking posix behavior)
and results in a command line with the trailing backslash doubled:
"C:\\windows\\system32\\cmd.exe /c DIR C:\\\\"; this one:

"/cygdrive/c/windows/system32/cmd.exe" "/c" "DIR" "C:\\"

works just fine (the resultant command line looks like this,
"C:\\windows\\system32\\cmd.exe /c DIR C:\\"; and obviously whatever
doubled the backslash in the above, does not kick in here);

but: the posix path in argv[0] is the same in both; so it must not be
the reason!

two probable causes are: special treatment of the magic three-argument
windows shell; or special-handling of an argument containing a space:

In order to be preserved the arg gets enveloped in double quotes, so
the trailing
backslash there would have caused a runaway string (the ending quote escaping)
and so it must be doubled for safety!

The latter also explains why "DIR C:\\ " (a trailing space) magically
works, too.

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