parentheses
This commit is contained in:
36
srcs/pipe.c
36
srcs/pipe.c
@ -6,7 +6,7 @@
|
||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/03/05 18:17:25 by marde-vr #+# #+# */
|
||||
/* Updated: 2024/04/22 19:49:36 by marde-vr ### ########.fr */
|
||||
/* Updated: 2024/04/23 14:47:24 by tomoron ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -27,10 +27,42 @@ void close_pipe_fds(t_msh *msh, int i)
|
||||
close(msh->fds[i][1]);
|
||||
}
|
||||
|
||||
void handle_parenthesis(t_msh *msh)
|
||||
{
|
||||
char *command;
|
||||
|
||||
command = 0;
|
||||
if(msh->cmds->cmd_type == PAREN)
|
||||
command = ft_strdup(msh->cmds->value);
|
||||
else if(msh->cmds->cmd_type == PIPE)
|
||||
command = ft_strdup(msh->cmds->next->value);
|
||||
if(!command)
|
||||
{
|
||||
ft_printf_fd(2, "an error occured");
|
||||
ft_exit(msh, 1);
|
||||
}
|
||||
free(msh->pids);
|
||||
free_cmd(msh->cmds_head);
|
||||
free_fds(msh);
|
||||
msh->in_type = 0;
|
||||
msh->out_type = 0;
|
||||
msh->in_fd = 0;
|
||||
msh->out_fd = 0;
|
||||
msh->locked_return_code = 0;
|
||||
exec_command_bonus(msh, command);
|
||||
free(command);
|
||||
ft_exit(msh, g_return_code);
|
||||
}
|
||||
|
||||
void execute_command(t_msh *msh, char **cmd_args)
|
||||
{
|
||||
char **env;
|
||||
|
||||
|
||||
if (is_parenthesis(msh->cmds))
|
||||
{
|
||||
free(cmd_args);
|
||||
handle_parenthesis(msh);
|
||||
}
|
||||
if (exec_builtin(msh))
|
||||
{
|
||||
free(cmd_args);
|
||||
|
Reference in New Issue
Block a user