[bug] globify dospath reacts poorly with escaped double quotes

Mingye Wang arthur200126@gmail.com
Tue Oct 8 09:05:00 GMT 2019


This bug is inherited from early versions of Cygwin. It's so old that
MSYS2 has this problem too.

There is no way of conveying a double quote in an argument once
globify() decides it has seen a dospath. Neither the `\"` nor `""`
work, because they are both unified to `\"` in quoted() and turned
into a `\\` pattern in globify().

This is problematic for programmers trying to write a routine to
reliably escape an argument for the Cygwin command-line.

A way to patch the problem is with a lookahead in globify():

if (dos_spec && *s == '\\') {
/**/p++ = '\\';
/**/if (s[1] == '"' && s[2]) {
/****/*p = *++s;
*p = *s;

[Apologies for the formatting; the gmail web editor hates leading spaces.]

(Note: The backslash thing has always been different from the MSCRT
handling, which only transforms backslashes followed by a double
quote. But this is fine as long as we are internally consistent.
Well... is it documented anywhere?)

Mingye Wang

Mingye Wang (Artoria2e5)

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