From b16d4b834d95d5cc0757d09e74fe6042e55f5440 Mon Sep 17 00:00:00 2001 From: Charles Cabergs Date: Thu, 10 Sep 2020 15:08:28 +0200 Subject: Added better error handling in eval --- src/builtin/exit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/builtin/exit.c') diff --git a/src/builtin/exit.c b/src/builtin/exit.c index 640fc01..52a4462 100644 --- a/src/builtin/exit.c +++ b/src/builtin/exit.c @@ -24,7 +24,7 @@ int builtin_exit(char **argv, t_env env) (void)env; if (argv[1] == NULL) - status = g_last_status_code; + status = g_last_status; else { errno = 0; -- cgit From 98990d5195e93154abbfd16eaa9d1fcc3572bc5c Mon Sep 17 00:00:00 2001 From: Charles Cabergs Date: Thu, 10 Sep 2020 19:46:07 +0200 Subject: Added errorf_ret helper, Removing error to status (just status code and fatal error) --- src/builtin/exit.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'src/builtin/exit.c') diff --git a/src/builtin/exit.c b/src/builtin/exit.c index 52a4462..a24efad 100644 --- a/src/builtin/exit.c +++ b/src/builtin/exit.c @@ -6,7 +6,7 @@ /* By: charles +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/04/01 17:10:16 by charles #+# #+# */ -/* Updated: 2020/08/20 17:31:18 by charles ### ########.fr */ +/* Updated: 2020/09/10 19:41:03 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -32,15 +32,9 @@ int builtin_exit(char **argv, t_env env) while (ft_isblank(*after)) after++; if (*after != '\0' || errno == ERANGE) - { - errorf("exit: %s: numeric argument required\n", argv[1]); - return (2); - } + return (errorf_ret(2, "exit: %s: numeric argument required\n", argv[1])); if (argv[2] != NULL) - { - errorf("exit: too many arguments\n"); - return (1); - } + return (errorf_ret(1, "exit: too many arguments\n")); } exit(status % 256); return (0); -- cgit