mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-05 23:18:08 +01:00
cmdgroup parsing: parse a single cmdlist
This commit is contained in:
parent
5379ad34f2
commit
3edff91107
3 changed files with 30 additions and 4 deletions
|
|
@ -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
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue