Greetings, Jeremy Drake!

>> cygwin does not treat \ as a quote if it is passed from non-cygwin shell.
>> When a Cygwin program is launched from a non-Cygwin shell, I personally
>> find it more natural for it to follow quoting semantics similar to Bash.
>>
>> I'm afraid that's not the case...
>>
>> > It sadly breaks builds driven by Windows-native tools since they expect
>> > the standard command line handling.

> What standard command line handling is that?  As a background, on Windows
> command lines are passed to processes as a single string, rather than as
> an array of strings like POSIX, and it is the responsibility of every
> process to make of that string what they will.  Because of the prevalance
> of C, this is ususally to split it into an argv[], but it doesn't have to
> be.

> The net result of this is that you not only have to worry about the
> quoting and escaping rules of your shell (do you escape with backslash?
> caret? backtick?), you also have to worry about the rules of the program
> being run (cmd.exe with or without /S, Cygwin vs Microsoft CRT).

> There is something of a de-facto "standard command line handling" which is
> "what msvcrt does to populate argv[] before calling main", but that's not
> foolproof either: reference a recent bruhaha about a "worst-fit"
> vulnerability.  It seems the crt will use best-fit and default replacement
> characters when converting the command line string from the native 2-byte
> unicode to the ansi codepage for char ** argv.  That can result in unicode
> quote characters turning into ascii quotes, and in unmappable unicode
> characters turning into question marks, which then might end up treated as
> wildcards by the application.

You're mixing the Win32 API execution parameters handling and CMD command
line parsing into one question. They are not the same, not directly related
even.

Much like bash, CMD (and PS too) have their own rules to build params from
command line.


-- 
With best regards,
Andrey Repin
Monday, August 4, 2025 14:37:23

Sorry for my terrible english...


-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

Reply via email to