🔨」 fix(builtins/exit): more than long long max is now an error, but why obj src

This commit is contained in:
yosyo
2024-07-29 12:15:11 +02:00
parent 92a0e3fafd
commit c3aad1290d

View File

@ -6,7 +6,7 @@
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */ /* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/07/14 13:46:57 by adjoly #+# #+# */ /* Created: 2024/07/14 13:46:57 by adjoly #+# #+# */
/* Updated: 2024/07/29 11:50:35 by mmoussou ### ########.fr */ /* Updated: 2024/07/29 12:13:37 by mmoussou ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -41,7 +41,7 @@ void exit_args_handler(char **argv, int ac, char **env_array, t_env *env)
get_exit_code(1); get_exit_code(1);
return ; return ;
} }
return_value = atoi(argv[1]); return_value = ft_atoi(argv[1]);
if (return_value == -1) if (return_value == -1)
return_value += 256; return_value += 256;
free_exit(env, env_array); free_exit(env, env_array);
@ -56,7 +56,8 @@ void ft_exit(char **argv, int ac, char **env_array, t_env *env)
free_exit(env, env_array); free_exit(env, env_array);
exit(get_exit_code(-1)); exit(get_exit_code(-1));
} }
if (check_exit_value(argv[1])) if (check_exit_value(argv[1])
|| (ft_atoi(argv[1]) % 10 != ft_atol(argv[1]) % 10))
{ {
printf("minishell: exit: %s: numeric argument required\n", argv[1]); printf("minishell: exit: %s: numeric argument required\n", argv[1]);
free_exit(env, env_array); free_exit(env, env_array);