Web lists-archives.com

Re: Quotes around command-line argument that has unicode characters are not removed

Am 22.03.2018 um 12:24 schrieb Andrey Repin:
when I put quotes around file that has
non-ASCII symbols, these quotes are passed to argv of the process literally,
otherwise they are removed. I would expect that there is a consistency.
Parameter unquoting done by the shell.
CMD does that differently from POSIX shells.
cmd.exe applies some inconsistent "smart" (in an MS sense...) magic quoting; it adds additional quotes if the parameter contains non-ASCII characters.
I have written a small C program that displays arguments, and run it three times:
You can also test this with cygwin /bin/echo:
C:\cygwin\bin>.\echo "bla"

C:\cygwin\bin>.\echo "blö"

This is also the reason why 'chere' fails on non-ASCII directories.

As one can see, the last run fails. I am a bit puzzled: how can I pass the name
of the file with space and Unicode symbols? I need to do it in uniform way, as I
am calling a Cygwin program from native Windows program, as in [1].
Due to the weird cmd.exe behaviour, you cannot. However, cygwin could apply a workaround by magic unquoting.


Any feedback is appreciated.
[1] https://sourceware.org/ml/cygwin/2016-05/msg00082.html
[2] http://daviddeley.com/autohotkey/parameters/parameters.htm
[3] https://cygwin.com/cygwin-ug-net/using-specialnames.html#pathnames-at
[4] https://github.com/openunix/cygwin/blob/master/winsup/cygwin/dcrt0.cc#L177

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