From 38630279546fbd3876fe2396f2afe4ca1bca9acc Mon Sep 17 00:00:00 2001 From: Charles Cabergs Date: Wed, 7 Oct 2020 12:27:26 +0200 Subject: Fixing parenthesis pipeline parsing, False negative unmatched quote on str --- src/eval/eval.c | 4 ++-- src/eval/operation.c | 25 +++++-------------------- 2 files changed, 7 insertions(+), 22 deletions(-) (limited to 'src/eval') diff --git a/src/eval/eval.c b/src/eval/eval.c index 2aed026..86d038e 100644 --- a/src/eval/eval.c +++ b/src/eval/eval.c @@ -6,7 +6,7 @@ /* By: charles +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/09/13 20:38:06 by charles #+# #+# */ -/* Updated: 2020/10/06 17:21:54 by cacharle ### ########.fr */ +/* Updated: 2020/10/07 10:25:39 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -17,7 +17,7 @@ int st_replace(int oldfd, int newfd) if (oldfd != FD_NONE) { dup2(oldfd, newfd); - close(oldfd); + /* close(oldfd); */ } return 0; } diff --git a/src/eval/operation.c b/src/eval/operation.c index 8442533..156f6f5 100644 --- a/src/eval/operation.c +++ b/src/eval/operation.c @@ -6,7 +6,7 @@ /* By: charles +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/06/17 15:27:22 by charles #+# #+# */ -/* Updated: 2020/10/06 17:31:43 by cacharle ### ########.fr */ +/* Updated: 2020/10/07 11:31:47 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -31,23 +31,6 @@ int eval_operation(int fds[2], t_env env, t_ast *ast) return (eval(right_fds, env, ast->op.right)); } -/* pid_t run_piped_child(t_env env, t_ast *ast, int copied, int closed) */ -/* { */ -/* pid_t pid; */ -/* int fds[2]; */ -/* */ -/* pid = fork(); */ -/* if (pid == 0) */ -/* { */ -/* dup2(copied, STDOUT_FILENO); */ -/* close(closed); */ -/* fds[0] = FD_NONE; */ -/* fds[1] = FD_NONE; */ -/* exit(eval(fds, env, ast, NULL, FD_NONE)); */ -/* } */ -/* return (pid); */ -/* } */ - int eval_pipeline(int fds[2], t_env env, t_ast *ast) { t_ftlst *curr; @@ -88,7 +71,6 @@ int eval_pipeline(int fds[2], t_env env, t_ast *ast) int pid = fork(); if (pid == 0) { - /* dup2(p[FD_WRITE], STDOUT_FILENO); */ if (prev_output != STDIN_FILENO) { dup2(prev_output, STDIN_FILENO); @@ -101,7 +83,10 @@ int eval_pipeline(int fds[2], t_env env, t_ast *ast) } close(p[FD_READ]); + int status = 0; + + waitpid(pid, &pid, 0); while (wait(NULL) != -1) ; - return (0); + return (WEXITSTATUS(pid)); } -- cgit