This commit is contained in:
Loic Deridder
2025-01-21 13:42:32 +01:00
parent 563349c2f8
commit 9dbc3f75e8
8 changed files with 149 additions and 79 deletions

View File

@@ -82,6 +82,10 @@ void builtin_exit(char *str, bool depth)
char *arg;
arg = get_arg(str);
long res = ft_atol(arg);
(void)res;
if (errno == ERANGE)
ft_printf("error numeric aarg\n");
if (depth == true)
{
if (count_arg(str) >= 2)
@@ -96,12 +100,12 @@ void builtin_exit(char *str, bool depth)
ft_putendl_fd(": numeric argument required", 2);
exit(2);
}
exit(ft_atoi(arg));
exit(ft_atoi(arg) % 256);
}
if (count_arg(str) >= 2)
bash_exiterrorcount();
else if (ft_isnumeric(arg))
bash_exit(ft_atoi(arg));
bash_exit(ft_atoi(arg) % 256);
else
bash_exit_errornum(arg);
}