update: normed lots of stuff
This commit is contained in:
parent
84a825cb0b
commit
678587d481
11 changed files with 325 additions and 300 deletions
|
|
@ -6,32 +6,35 @@
|
|||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/09/14 12:31:28 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/09/14 12:31:47 by maiboyer ### ########.fr */
|
||||
/* Updated: 2024/09/16 18:28:48 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "exec/_run_ast.h"
|
||||
|
||||
t_error _run_get_exit_code(t_ast_node self, t_state *state, int *out)
|
||||
t_error _run_cmd(t_ast_node self, t_state *state, int *out)
|
||||
{
|
||||
t_command_result cmd_res;
|
||||
|
||||
if (run_command(\
|
||||
&self->data.command, state, (t_cmd_pipe){NULL, false}, &cmd_res))
|
||||
return (ERROR);
|
||||
if (cmd_res.process.stdin != NULL)
|
||||
close_fd(cmd_res.process.stdin);
|
||||
if (cmd_res.process.stdout != NULL)
|
||||
close_fd(cmd_res.process.stdout);
|
||||
if (cmd_res.process.stderr != NULL)
|
||||
close_fd(cmd_res.process.stderr);
|
||||
*out = cmd_res.exit;
|
||||
return (NO_ERROR);
|
||||
}
|
||||
|
||||
t_error _run_other(t_ast_node self, t_state *state, int *out)
|
||||
{
|
||||
t_pipeline_result pipe_res;
|
||||
t_list_result list_res;
|
||||
t_subshell_result subshell_res;
|
||||
|
||||
if (self->kind == AST_COMMAND)
|
||||
{
|
||||
if (run_command(\
|
||||
&self->data.command, state, (t_cmd_pipe){NULL, false}, &cmd_res))
|
||||
return (ERROR);
|
||||
if (cmd_res.process.stdin != NULL)
|
||||
close_fd(cmd_res.process.stdin);
|
||||
if (cmd_res.process.stdout != NULL)
|
||||
close_fd(cmd_res.process.stdout);
|
||||
if (cmd_res.process.stderr != NULL)
|
||||
close_fd(cmd_res.process.stderr);
|
||||
*out = cmd_res.exit;
|
||||
}
|
||||
if (self->kind == AST_PIPELINE)
|
||||
{
|
||||
if (run_pipeline(&self->data.pipeline, state, &pipe_res))
|
||||
|
|
@ -53,3 +56,10 @@ t_error _run_get_exit_code(t_ast_node self, t_state *state, int *out)
|
|||
}
|
||||
return (NO_ERROR);
|
||||
}
|
||||
|
||||
t_error _run_get_exit_code(t_ast_node self, t_state *state, int *out)
|
||||
{
|
||||
if (self->kind == AST_COMMAND)
|
||||
return (_run_cmd(self, state, out));
|
||||
return (_run_other(self, state, out));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue