From d3deaaebf0af3af5539837328cb3cb76b9833fae Mon Sep 17 00:00:00 2001 From: narnaud Date: Wed, 11 May 2022 01:30:51 +0200 Subject: [PATCH] fix: halt calls, new: debug define --- built-in.c | 6 +++--- caller.c | 10 +++++----- minishell.h | 3 ++- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/built-in.c b/built-in.c index e8d82c8..a5dc0ba 100755 --- a/built-in.c +++ b/built-in.c @@ -6,7 +6,7 @@ /* By: narnaud +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/01/06 09:02:57 by narnaud #+# #+# */ -/* Updated: 2022/05/07 23:17:15 by narnaud@stude ### ########.fr */ +/* Updated: 2022/05/11 01:27:56 by narnaud@stude ### ########.fr */ /* */ /* ************************************************************************** */ @@ -78,8 +78,8 @@ int ft_cd(t_command *cmd) int ft_exit(t_datas *datas, t_command *cmd) { if (cmd->argc > 1) - halt(datas, EXIT_SUCCESS); + halt(datas, EXIT_SUCCESS, 0); else - halt(datas, ft_atoi(cmd->argv[1])); + halt(datas, ft_atoi(cmd->argv[1]), 0); return (1); } diff --git a/caller.c b/caller.c index 1bafbbd..9a55fae 100755 --- a/caller.c +++ b/caller.c @@ -6,7 +6,7 @@ /* By: mea +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/05/03 11:48:16 by narnaud #+# #+# */ -/* Updated: 2022/05/11 01:15:39 by narnaud@stude ### ########.fr */ +/* Updated: 2022/05/11 01:24:29 by narnaud@stude ### ########.fr */ /* */ /* ************************************************************************** */ @@ -72,18 +72,18 @@ int piper(t_datas *datas, t_command *cmd) close(cmd->fd[1]); if (cmd->fd[0]) close(cmd->fd[0]); - printf("%s -ope: %d, pid: %d, fdin: %d, fdout: %d\n", cmd->argv[0], cmd->ope, pid, cmd->fd[0], cmd->fd[1]); + if (DEBUG) + printf("%s -ope: %d, pid: %d, fdin: %d, fdout: %d\n", cmd->argv[0], cmd->ope, pid, cmd->fd[0], cmd->fd[1]); if (cmd->ope == PIPE) pid = piper(datas, cmd->next); else { waitpid(pid, &status, 0); exit_code = handle_status(datas, status); - if (!cmd->next) - datas->exit_code = exit_code; - else if (cmd->next && ((cmd->ope == AND && !exit_code) \ + if (cmd->next && ((cmd->ope == AND && !exit_code) \ || (cmd->ope == OR && exit_code))) piper(datas, cmd->next); + datas->exit_code = exit_code; } return (1); } diff --git a/minishell.h b/minishell.h index 6364c19..f0f0ed7 100755 --- a/minishell.h +++ b/minishell.h @@ -6,7 +6,7 @@ /* By: mea +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/05/02 13:50:44 by narnaud #+# #+# */ -/* Updated: 2022/05/11 00:24:26 by narnaud@stude ### ########.fr */ +/* Updated: 2022/05/11 01:24:53 by narnaud@stude ### ########.fr */ /* */ /* ************************************************************************** */ @@ -15,6 +15,7 @@ # define ENVP_MAX_SIZE 1024 # define STR_MAX_SIZE 1024 # define PATHS_MAX_SIZE 126 +# define DEBUG 1 # include "libft/libft.h" # include