From 0f0d3ea0bde1dec87703439370f82c89fd9739c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kha=C3=AFs=20COLIN?= Date: Thu, 13 Mar 2025 17:20:26 +0100 Subject: [PATCH] notes: new architecture for cmdgroup --- NOTES.md | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 73 insertions(+), 6 deletions(-) diff --git a/NOTES.md b/NOTES.md index 4877038..9ccb65b 100644 --- a/NOTES.md +++ b/NOTES.md @@ -208,26 +208,93 @@ not remain in effect after the subshell completes. The exit status of this construct is the exit status of LIST. ```c -struct s_cmdgroup; +typedef enum e_cmdgroup_item_type +{ + TYPE_INVALID, + TYPE_CMDGROUP, + TYPE_PIPELINE, +} t_cmdgroup_item_type; -typedef struct s_cmdgroup_item +typedef struct s_cmdlist_item { enum e_cmdgroup_item_type type; union u_cmdgroup_item_inner { t_cmdgroup *cmdgroup; - struct s_cmdlist *cmdlist; + struct s_pipeline *pipeline; } inner; } t_cmdgroup_item; +typedef s_cmdlist +{ + struct s_cmdlist_item *cmds; + int num_cmds; + struct s_operators *operators; +} t_cmdlist; + typedef struct s_cmdgroup { - int item_num; - struct s_cmdgroup_item *items; - struct s_redirects *redirections; + struct s_cmdlist item; + struct s_redirection_list *redirections; } t_cmdgroup; ``` +```c +// (cmd1) && (cmd2) + +t_cmdgroup +{ + item = t_cmdlist + { + cmds = [ + t_cmdlist_item + { + type = TYPE_CMDGROUP + inner = t_cmdgroup + { + item = t_cmdlist + { + cmds = [ + t_cmdlist_item + { + type = TYPE_PIPELINE + inner = t_pipeline "cmd1" + } + ] + num_cmds = 1 + operators = [OP_END] + } + redirections = NULL + } + } + t_cmdlist_item + { + type = TYPE_CMDGROUP + inner = t_cmdgroup + { + item = t_cmdlist + { + cmds = [ + t_cmdlist_item + { + type = TYPE_PIPELINE + inner = t_pipeline "cmd2" + } + ] + num_cmds = 1 + operators = [OP_END] + } + redirections = NULL + } + } + ] + num_cmd = 2 + operators = [OP_AND, OP_END] + } + redirections = NULL +} +``` + ### Shell Expansion cf. 3.5 Shell Expansions