From 5948237aadcd054cc3b0a104b430af4128b5fac5 Mon Sep 17 00:00:00 2001 From: Etienne Rey-bethbeder Date: Tue, 28 Feb 2023 14:25:20 +0100 Subject: [PATCH] OBELIX: MAIS ASTERIX ARRETE TOUT DE SUITE --- builtins/cd.c | 6 +++--- builtins/exit.c | 14 ++++++++------ builtins/export.c | 21 +++++++++++++++------ 3 files changed, 26 insertions(+), 15 deletions(-) diff --git a/builtins/cd.c b/builtins/cd.c index 649b6bf..78791c5 100644 --- a/builtins/cd.c +++ b/builtins/cd.c @@ -6,7 +6,7 @@ /* By: erey-bet +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/02/20 14:27:36 by erey-bet #+# #+# */ -/* Updated: 2023/02/28 13:13:23 by erey-bet ### ########.fr */ +/* Updated: 2023/02/28 13:37:18 by erey-bet ### ########.fr */ /* */ /* ************************************************************************** */ @@ -27,7 +27,7 @@ int move_folder(char **args, int fd) { if (chdir(path) == 0) return (0); - write(2, "chdir error", 11); + write(2, "No suck file or directory", 25); return (1); } else @@ -40,7 +40,7 @@ int move_folder(char **args, int fd) return (0); } free(join); - write(2, "chdir error", 11); + write(2, "No suck file or directory", 25); return (1); } } diff --git a/builtins/exit.c b/builtins/exit.c index d2cbfea..457e3ba 100644 --- a/builtins/exit.c +++ b/builtins/exit.c @@ -6,7 +6,7 @@ /* By: erey-bet +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/02/24 10:17:59 by erey-bet #+# #+# */ -/* Updated: 2023/02/24 12:44:05 by erey-bet ### ########.fr */ +/* Updated: 2023/02/28 14:24:47 by erey-bet ### ########.fr */ /* */ /* ************************************************************************** */ @@ -27,16 +27,18 @@ static int error(int err, char *reason, char *problem, int fd) int ft_exit(char **args, int fd) { - int i; + int err; if (args[0] == NULL) return (0); - i = -1; - if (ft_atoi_check(args[0]) == 0) - return (error(2, "numeric argument required", args[0], fd)); + err = ft_atoi_check; + if (err == 1) + return (error(err, "numeric argument required", args[0], fd)); if (args[1] != NULL) return (error(-1, "too many arguments", NULL, fd)); - return (ft_atoi(args[0])); + if (error > 0) + error(err, "numeric argument required", args[0], fd); + return (ft_atoi(args[0]) % 256); } /* int main(int argc, char *argv[]) */ diff --git a/builtins/export.c b/builtins/export.c index 92d6520..5a632ed 100644 --- a/builtins/export.c +++ b/builtins/export.c @@ -6,7 +6,7 @@ /* By: cchauvet