pipeline.c refactoring

This commit is contained in:
LuckyLaszlo
2021-12-21 17:34:44 +01:00
parent 54c9df31e4
commit 638dbbaf9c

View File

@@ -26,17 +26,21 @@ int pipeline(t_all *c)
return (0); return (0);
if (!pipeline_find_access(pipeline, c->path)) if (!pipeline_find_access(pipeline, c->path))
return (0); return (0);
if (pipeline[0]->builtin_f && ft_2d_arrlen(pipeline) == 1) if (ft_2d_arrlen(pipeline) > 1)
wait_subshell(pipeline_exec(pipeline, c));
else
{ {
if (!pipeline[0]->error) if (pipeline[0]->error)
set_last_exit_status(pipeline[0]->error);
else if (pipeline[0]->builtin_f)
{ {
ret = simple_command_builtin(pipeline[0], c); ret = simple_command_builtin(pipeline[0], c);
if (ret != EXIT_SUCCESS) if (ret != EXIT_SUCCESS)
set_last_exit_status(ret); set_last_exit_status(ret);
} }
else
wait_subshell(pipeline_exec(pipeline, c));
} }
else
wait_subshell(pipeline_exec(pipeline, c));
free_pipeline(&c->pipeline); free_pipeline(&c->pipeline);
return (1); return (1);
} }