Parser for cmd language?

Dan Kegel dank at
Thu Dec 17 03:57:26 CST 2009

There are lots of bugs filed for little (or big) problems in wine's cmd
that involve parsing the command language:

21047	cmd does not handle for %%a in ('command')
21046	cmd does not handle all operators in 'if' command
20161	cmd can't handle echo commands containing quotes and redirection
19784	cmd doesn't handle ( ) scoping; breaks firefox build
18712	cmd: "if defined ... " command crashes.
18407	cmd.exe: set command seems broken
18346	cmd does not support the "^" escape character
18057	cmd.exe: mishandled quoted built-in commands with parameters
(programs/cmd/wcmdmain.c: has_space==1 && opt_s==0)
15359	cmd's "for" command doesn't handle /F. Breaks msysgit, firefox build.

The existing parser in cmd is pretty weak.  I wonder if it might not
be time to write a new parser -- either using some parser generator
tool, or more likely, a plain old recursive descent parser --
that can handle the language better.

Also, some of the builtins need to be split out into separate
executables, see e.g.
18059 - Unity Indie Trial exits because attrib.exe is missing
(which might relax the requirements on the parser inside cmd slightly)

More information about the wine-devel mailing list