This commit is contained in:
Quinten 2025-02-23 11:58:13 +01:00
parent 8da0e0a036
commit 24752c9d08
2 changed files with 79 additions and 39 deletions

View File

@ -28,6 +28,7 @@ t_list *parser_get_commands(t_minishell *minishell)
token = (t_token *) current->content;
command = parser_command_new(ft_strdup(token->value));
command->args = parser_get_arguments(current, minishell);
command->redirect_in = parser_get_input_redirects(current);
ft_lstadd_back(&command_list, ft_lstnew(command));
while (current && ((t_token *)current->content)->type < 3)
current = current->next;

View File

@ -0,0 +1,39 @@
# include "minishell.h"
static int valid_def(t_list *list, t_token *token)
{
t_token *next;
if (!list->next)
return (0);
next = (t_token *)list->next->content;
if (!next)
return (0);
return ((token->type == T_REDIRECT_IN || token->type == T_HEREDOC) && next->type < 3);
}
static t_redirect *redirect_new()
{
t_redirect *result;
}
void parser_get_input_redirects(t_list *list)
{
t_list *current;
t_list *redirects;
t_token *token;
redirects = NULL;
current = list;
while (current)
{
token = (t_token *)current->content;
if (valid_def(current, token))
{
ft_lstaddfront(&redirects, ft_lstnew());
}
else
break ;
current = current->next;
}
}