feat: Redirections applied

Now redirections work.
> redirects to a file
< reads the content of a file and set it to the input of a command
>> append the output of a command into a file
This commit is contained in:
marcnava-42cursus
2026-02-12 20:28:05 +01:00
parent 3c7ee5b161
commit 6bc2eab19b
8 changed files with 141 additions and 1 deletions

View File

@@ -24,6 +24,8 @@ void executor_child_process(
command = current_command->content;
executor_setup_child_input(pipeline);
executor_setup_child_output(current_command, pipeline);
if (!executor_apply_redirections(command, NULL, NULL))
exit(EXIT_FAILURE);
exit_status = executor_execute_command(command, minishell);
exit(exit_status);
}
@@ -85,6 +87,16 @@ static void cmdfree_argv(
free(argv);
}
static void cmdfree_redirection(
t_redirection *redirection
)
{
if (redirection == NULL)
return ;
free(redirection->target);
free(redirection);
}
void executor_cmdfree(
t_command *command
)
@@ -93,5 +105,8 @@ void executor_cmdfree(
return ;
cmdfree_argv(command->argv);
free(command->path);
ft_lstclear(&command->redirections,
(void (*)(void *))cmdfree_redirection);
ft_lstclear(&command->heredocs, (void (*)(void *))cmdfree_redirection);
free(command);
}