[bug?] Spawning cygwin32 program from cygwin64 messes up backslashes

Mingye Wang arthur200126@gmail.com
Thu Jun 11 01:05:23 GMT 2020


The following test case script fails under cygwin64:

out32=$(/cygdrive/c/cygwin/bin/echo.exe 'a\\ b')
out64=$(/cygdrive/c/cygwin64/bin/echo.exe 'a\ b')
test "$out32" = "$out64"

In other words, while the correct (by-argv-memory) result is `a\\ b`,
cygwin32 gives `a\ b` as output instead. The test case works fine when
CYGWIN=noglob is set, but then `echo.exe 'a\" b'` fails miserably.

The problem is that a cygwin32 program, when run from cygwin64, takes
the code path of normal (non-cygwin) programs. The argv is translated
according to MSVCRT rules in linebuf::fromargv(), but on the receiving
side cygwin's build_argv() is incompatible with MSVCRT rules.

The question mark on the [bug] is due to the apparent old age of this
very unique parsing code and some features it implies. The whole
`winshell` name is pretty bad to start with, since it's really more
relevant to the configurable glob setting as a cygwin parent would
have filled in a `cygheap_exec_info` structure anyways. The link
between globify and quoted is also pretty wild to go through. I mean,
there's nothing sane about cmdline globbing under windows, but a good
place to start is trying to do MSVCRT quoting. The glob rewriting in
globify() should probably go into quoted() for reader's sanity too.

Mingye Wang (Artoria2e5)

More information about the Cygwin mailing list