notes: new architecture for cmdgroup

This commit is contained in:
Khaïs COLIN 2025-03-13 17:20:26 +01:00
parent d8dd1613c8
commit 0f0d3ea0bd
Signed by: logistic-bot
SSH key fingerprint: SHA256:RlpiqKeXpcPFZZ4y9Ou4xi2M8OhRJovIwDlbCaMsuAo

View file

@ -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