diff --git a/codes/builtins/builtin_exit.c b/codes/builtins/builtin_exit.c index 119af7a..c4133be 100644 --- a/codes/builtins/builtin_exit.c +++ b/codes/builtins/builtin_exit.c @@ -6,7 +6,7 @@ /* By: kyungjle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/03/27 06:04:41 by nicknamemoh #+# #+# */ -/* Updated: 2024/04/09 14:59:46 by kyungjle ### ########.fr */ +/* Updated: 2024/04/10 16:34:46 by kyungjle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -26,7 +26,6 @@ will return with argument given (0 if no argument given) */ int builtin_exit(char *args[], t_ld_map_env *env) { - printf("exit\n"); if (!builtin_check_argument_count((const char **) args, 2)) return (1); if (args[1] != NULL) @@ -34,10 +33,11 @@ int builtin_exit(char *args[], t_ld_map_env *env) if (!check_digit(args[1])) exit (255); free_ld_map(env); + write(2, "exit\n", 5); exit(ft_atoi(args[1])); } - else - exit(EXIT_SUCCESS); + write(2, "exit\n", 5); + exit(EXIT_SUCCESS); } /* @@ -50,13 +50,18 @@ check for string is only digit static t_bool check_digit(const char *c) { const char *ptr; + char *msg; ptr = c; while (*c != '\0') { if (!ft_isdigit(*c)) { - printf("exit: %s: numeric argument required\n", ptr); + msg = malloc((ft_strlen(ptr) + 36) * sizeof(char)); + *msg = '\0'; + ft_sprintf(msg, "exit: %s: numeric argument required\n", ptr); + write(2, msg, ft_strlen(msg)); + free(msg); return (FALSE); } c++; @@ -84,7 +89,7 @@ t_bool builtin_check_argument_count(const char *args[], int limit) } if (count > limit) { - printf("too many arguments\n"); + write(2, "exit: too many arguments\n", 25); return (FALSE); } else diff --git a/codes/loader/ldexec_findexec.c b/codes/loader/ldexec_findexec.c index 42e530e..959617f 100644 --- a/codes/loader/ldexec_findexec.c +++ b/codes/loader/ldexec_findexec.c @@ -6,7 +6,7 @@ /* By: kyungjle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/03/13 16:47:55 by nicknamemoh #+# #+# */ -/* Updated: 2024/04/09 17:48:24 by kyungjle ### ########.fr */ +/* Updated: 2024/04/10 16:25:48 by kyungjle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -59,10 +59,10 @@ char *ldexec_exec_find_f(char *cmd, t_bool *need_free, const char *path) else return (check_relative_f(cmd)); } - ret = check_cwd_f(cmd); + ret = check_env_path_f(cmd, path); if (ret != NULL) return (ret); - ret = check_env_path_f(cmd, path); + ret = check_cwd_f(cmd); return (ret); }