fixed the list issue

This commit is contained in:
Maieul BOYER 2024-08-14 17:39:42 +02:00
parent f4f749830f
commit 42e1b718a2
No known key found for this signature in database
3 changed files with 5 additions and 11 deletions

View file

@ -6,7 +6,7 @@
# By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ # # By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ # # +#+#+#+#+#+ +#+ #
# Created: 2023/11/12 11:05:05 by rparodi #+# #+# # # Created: 2023/11/12 11:05:05 by rparodi #+# #+# #
# Updated: 2024/08/12 17:53:35 by rparodi ### ########.fr # # Updated: 2024/08/14 17:36:13 by maiboyer ### ########.fr #
# # # #
# **************************************************************************** # # **************************************************************************** #
@ -44,7 +44,7 @@ endif
endif endif
# TODO: ADD THIS WHEN FINISHING THIS: # TODO: ADD THIS WHEN FINISHING THIS:
CFLAGS_ADDITIONAL += -DNVALGRIND # CFLAGS_ADDITIONAL += -DNVALGRIND
CFLAGS_ADDITIONAL += -O0 -Wno-cpp CFLAGS_ADDITIONAL += -O0 -Wno-cpp
# TODO: REMOVE THIS WHEN FINISHING THIS: # TODO: REMOVE THIS WHEN FINISHING THIS:

View file

@ -6,7 +6,7 @@
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */ /* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/07/26 10:55:52 by rparodi #+# #+# */ /* Created: 2024/07/26 10:55:52 by rparodi #+# #+# */
/* Updated: 2024/08/12 16:35:07 by maiboyer ### ########.fr */ /* Updated: 2024/08/14 17:37:41 by maiboyer ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -469,7 +469,7 @@ t_error build_sym_list(t_parse_node self, t_const_str input, t_ast_node *out)
} }
else if (ts_node_field_id_for_child(self, i) == field_op) else if (ts_node_field_id_for_child(self, i) == field_op)
{ {
temp = ts_node_symbol(ts_node_child(self, i)); temp = ts_node_grammar_symbol(ts_node_child(self, i));
if (temp == anon_sym_PIPE_PIPE) if (temp == anon_sym_PIPE_PIPE)
ret->data.list.op = AST_LIST_OR; ret->data.list.op = AST_LIST_OR;
if (temp == anon_sym_AMP_AMP) if (temp == anon_sym_AMP_AMP)

View file

@ -6,7 +6,7 @@
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */ /* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/07/11 17:22:29 by maiboyer #+# #+# */ /* Created: 2024/07/11 17:22:29 by maiboyer #+# #+# */
/* Updated: 2024/08/13 17:08:05 by maiboyer ### ########.fr */ /* Updated: 2024/08/14 17:39:16 by maiboyer ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -577,7 +577,6 @@ t_error run_list(t_ast_list *list, t_state *state, t_list_result *out)
if (list == NULL || state == NULL || out == NULL) if (list == NULL || state == NULL || out == NULL)
return (ERROR); return (ERROR);
append = NULL; append = NULL;
printf("LIST\n");
if (list->right->kind == AST_COMMAND) if (list->right->kind == AST_COMMAND)
append = &list->right->data.command.suffixes_redirections; append = &list->right->data.command.suffixes_redirections;
if (list->right->kind == AST_PIPELINE) if (list->right->kind == AST_PIPELINE)
@ -595,9 +594,6 @@ t_error run_list(t_ast_list *list, t_state *state, t_list_result *out)
right = -1; right = -1;
if (_run_get_exit_code(list->left, state, &left)) if (_run_get_exit_code(list->left, state, &left))
return (ERROR); return (ERROR);
printf("left == %i\n", left);
printf("(list->op == AST_LIST_AND && left == 0) == %s\n", (list->op == AST_LIST_AND && left == 0) ? "true" : "false");
printf("(list->op == AST_LIST_OR && left != 0) == %s\n", (list->op == AST_LIST_OR && left != 0) ? "true" : "false");
if ((list->op == AST_LIST_OR && left != 0) || (list->op == AST_LIST_AND && left == 0)) if ((list->op == AST_LIST_OR && left != 0) || (list->op == AST_LIST_AND && left == 0))
{ {
if (_run_get_exit_code(list->right, state, &right)) if (_run_get_exit_code(list->right, state, &right))
@ -852,8 +848,6 @@ t_error _spawn_cmd_and_run(t_vec_str args, t_vec_ast redirection, t_state *state
info = (t_spawn_info){}; info = (t_spawn_info){};
if (cmd_pipe.input != NULL) if (cmd_pipe.input != NULL)
info.stdin = fd(cmd_pipe.input); info.stdin = fd(cmd_pipe.input);
if (cmd_pipe.input != NULL && !(cmd_pipe.input->perms & FD_READ))
printf("PERMISSION ERROR for %s !\n", cmd_pipe.input->name);
if (cmd_pipe.create_output) if (cmd_pipe.create_output)
info.stdout = piped(); info.stdout = piped();
i = 0; i = 0;