From e7f8373b4a37cb099a269f067ac3a504817dccfe Mon Sep 17 00:00:00 2001 From: Camille Chauvet Date: Tue, 28 Feb 2023 15:21:47 +0100 Subject: [PATCH] c la merde --- cmd.c | 4 ++-- execution.c | 5 ++++- spacer.c | 3 ++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/cmd.c b/cmd.c index 351f250..2decebf 100644 --- a/cmd.c +++ b/cmd.c @@ -23,8 +23,8 @@ void ft_cmddel(void *ptr) if (content->executable != NULL) free(content->executable); if (content->fd_in > 2) - close(content->fd_out); - if (content->fd_in > 2) + close(content->fd_in); + if (content->fd_out > 2) close(content->fd_out); free(content); } diff --git a/execution.c b/execution.c index 5525ae4..871755f 100644 --- a/execution.c +++ b/execution.c @@ -118,13 +118,16 @@ static int ft_own_cmd(t_data *data, t_cmd *cmd) else if (ft_strcmp(cmd->executable, "exit") == 0) { exit_code = ft_exit(cmd->args + 1); - if (exit_code != -1) + if (exit_code > -1) { data->exit_code = exit_code; return_code = -2; } else + { + data->exit_code = 1; return_code = -3; + } } if (return_code >= 0) data->exit_code = return_code; diff --git a/spacer.c b/spacer.c index 15ef492..ebda46d 100644 --- a/spacer.c +++ b/spacer.c @@ -38,7 +38,8 @@ static char *ft_spacer_after(const char *str) if (out == NULL) return (NULL); } - i++; + if (out[i] != '\0') + i++; } return (out); }