cmdgroup parsing: parse a single cmdlist

This commit is contained in:
Khaïs COLIN 2025-03-19 11:28:32 +01:00
parent 5379ad34f2
commit 3edff91107
Signed by: logistic-bot
SSH key fingerprint: SHA256:RlpiqKeXpcPFZZ4y9Ou4xi2M8OhRJovIwDlbCaMsuAo
3 changed files with 30 additions and 4 deletions

View file

@ -0,0 +1,22 @@
It "parses null for empty command"
Data
#|
End
When call ./minishell
The output should eq ""
End
It "a single command is parsed"
Data
#|echo hello
End
When call ./minishell
The output should eq \
" ╰─ t_cmdgroup
├─ t_cmdlist
│ ├─ num_cmds = 1
│ ╰─ cmd[0]
╰─ t_redir_list"
End

View file

@ -6,7 +6,7 @@
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/03/11 15:18:02 by khais #+# #+# */
/* Updated: 2025/03/18 15:54:18 by khais ### ########.fr */
/* Updated: 2025/03/19 11:26:34 by khais ### ########.fr */
/* */
/* ************************************************************************** */
@ -26,11 +26,15 @@ t_cmdgroup *cmdgroup_from_wordlist(t_wordlist *words)
cmd = ft_calloc(1, sizeof(t_cmdgroup));
if (cmd == NULL)
return (NULL);
cmd->item = cmdlist_from_wordlist(words);
return (cmd);
}
void cmdgroup_destroy(t_cmdgroup *cmd)
{
if (cmd == NULL)
return ;
cmdlist_destroy(cmd->item);
free(cmd);
}
@ -40,7 +44,7 @@ void cmdgroup_debug(t_cmdgroup *cmd, t_buffer **leader, bool is_last)
return ;
indent(leader, is_last);
ft_printf("%s\n", "t_cmdgroup");
cmdlist_debug(&cmd->item, leader, false);
cmdlist_debug(cmd->item, leader, false);
redir_list_debug(cmd->redirections, leader, true);
dedent(leader, is_last);
}

View file

@ -6,7 +6,7 @@
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/03/11 15:11:57 by khais #+# #+# */
/* Updated: 2025/03/18 15:03:31 by khais ### ########.fr */
/* Updated: 2025/03/19 11:26:22 by khais ### ########.fr */
/* */
/* ************************************************************************** */
@ -27,7 +27,7 @@ typedef struct s_cmdgroup
/*
** list of the commands inside this group
*/
struct s_cmdlist item;
struct s_cmdlist *item;
/*
** redirections to apply to the whole group
*/