[PATCH v2] Cygwin: rewrite cmdline parser

Corinna Vinschen corinna-cygwin@cygwin.com
Tue Jun 30 10:30:40 GMT 2020


Hi Mingye,

On Jun 25 22:43, Mingye Wang wrote:
> This commit rewrites the cmdline parser to achieve the following:
> * MSVCRT compatibility. Except for the single-quote handling (an
>   extension for compatibility with old Cygwin), the parser now
>   interprets option boundaries exactly like MSVCR since 2008. This fixes
>   the issue where our escaping does not work with our own parsing.
> * Clarity. Since globify() is no longer responsible for handling the
>   opening and closing of quotes, the code is much simpler.
> * Sanity. The GLOB_NOCHECK flag is removed, so a failed glob correctly
>   returns the literal value. Without the change, anything path-like
>   would be garbled by globify's escaping.
> 
> Some clarifications are made in the documentation for when globs are not
> expanded.  A minor change was made to insert_file to remove the memory
> leak with multiple files.
> 
> The change fixes two complaints of mine:
> * That cygwin is incompatible with its own escape.[1]
> * That there is no way to echo `C:\"` from win32.[2]
>   [1]: https://cygwin.com/pipermail/cygwin/2020-June/245162.html
>   [2]: https://cygwin.com/pipermail/cygwin/2019-October/242790.html
> 
> (It's never the point to spawn cygwin32 from cygwin64. Consistency
> matters: with yourself always, and with the outside world when you are
> supposed to.)

Apart from the small free() problem, you mention in your reply to self,
this patch looks great at first glance.

Three questions/requests if you don't mind:

- Would you mind to send the corrected version yet?

- A contribution like this still(*) requires the 2-clause BSD waiver per
  the winsup/CONTRIBUTORS file, see the chapter "Before you get started"
  on https://cygwin.com/contrib.html

- Can you please take a bit of time and try to outline in how far this
  change introduces backward compatibility problems with the old code?
  I don't mean the obvious bug like the backslash problem, but rather
  the question is, what input did something useful before which doesn't
  work the same way now?  I'd like to get a feeling how much this may
  affect existing scripts.


Thanks,
Corinna


(*) IIRC, 2020 is the last year requiring this...

-- 
Corinna Vinschen
Cygwin Maintainer


More information about the Cygwin-patches mailing list