This is the third serie related to rewriting cmd's command engine.
Currently, cmd stores block of commands as a linked list of CMD_LIST.
Even for nested commands (like 'if' command inside a 'for' command), it's
parsed as a single list of commands, using a 'depth' attribute and marker
for end of block to describe the structure.
This leads to several issues:
- parsing for nested commands is not 100% robust,
- chaining of commands (and its precedence) is not handled,
- no separation between parsing and execution (esp. for 'IF' and 'FOR'
commands, which behave slightly differently than regular commands
when dealing with variables with delayed expansion),
- data model doesn't 100% fit native behavior (eg redirections can
apply to a block of commands, whereas redirections are attached
to individual commands)
- ...
The final goal is to replace this with:
- a tree of commands:
+ binary nodes for command chaining,
+ 'IF' and 'FOR' commands being parsed and stored as such
+ leaf being a command
It will require a couple more series to reach that goal, so
this series puts in place the basic building bits:
- introducing a new structure CMD_NODE to hold that each node
of such a tree,
- moving the chaining operator into that CMD_NODE (meaning
that we move from a linked list to a binary tree degenerated
into a list: left is command, right is next node).
--
v2: programs/cmd: Move operator from CMD_COMMAND to CMD_NODE.
programs/cmd: Add helpers to handle list in degenerated binary tree.
programs/cmd: Introduce CMD_NODE structure.
programs/cmd: Remove malloc attribute from xrealloc.
https://gitlab.winehq.org/wine/wine/-/merge_requests/5609
The original help info of MKLINK lacks **\\t** which makes the output text of wine cmd not fully aligned.
![before](/uploads/659f487299f8b25ab4211e111323a5c3/before.png){width="587" height="330"}
![after](/uploads/0c3a6b7dc1a5326555fe033fdf522953/after.png){width="586" height="330"}
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/5621