aboutsummaryrefslogtreecommitdiff
path: root/src/eval
diff options
context:
space:
mode:
authorCharles Cabergs <me@cacharle.xyz>2020-10-07 12:27:26 +0200
committerCharles Cabergs <me@cacharle.xyz>2020-10-07 12:27:26 +0200
commit38630279546fbd3876fe2396f2afe4ca1bca9acc (patch)
tree3b08fa1524722334afbafc5155c96e4ee488862e /src/eval
parent22ff0337dc23239c32cc738bb6f576b8a0b66f8b (diff)
downloadminishell-38630279546fbd3876fe2396f2afe4ca1bca9acc.tar.gz
minishell-38630279546fbd3876fe2396f2afe4ca1bca9acc.tar.bz2
minishell-38630279546fbd3876fe2396f2afe4ca1bca9acc.zip
Fixing parenthesis pipeline parsing, False negative unmatched quote on str
Diffstat (limited to 'src/eval')
-rw-r--r--src/eval/eval.c4
-rw-r--r--src/eval/operation.c25
2 files changed, 7 insertions, 22 deletions
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 <me@cacharle.xyz> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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 <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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));
}