From 97e7e9b9934f99fbc659445512b19a525802726c Mon Sep 17 00:00:00 2001 From: Charles Cabergs Date: Fri, 9 Oct 2020 09:16:17 +0200 Subject: Fixing empty PATH variable bug --- src/path.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/path.c') diff --git a/src/path.c b/src/path.c index 61c6cf7..ac66b1e 100644 --- a/src/path.c +++ b/src/path.c @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/27 15:51:01 by cacharle #+# #+# */ -/* Updated: 2020/10/07 12:24:27 by cacharle ### ########.fr */ +/* Updated: 2020/10/09 09:15:09 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -66,7 +66,14 @@ int path_search( return (st_path_check(exec_path, false)); } if ((current_dir = env_search(env, "PATH", NULL)) == NULL) - return (st_dir_search(getcwd(cwd, PATH_MAX + 1), exec_name, exec_path)); + return (st_path_check(ft_strcpy(exec_path, exec_name), false)); + if (*current_dir == '\0') + { + ft_strcpy(exec_path, exec_name); + if (print) + return (st_path_check(exec_name, false)); + return (0); + } while ((collon = ft_strchr(current_dir, ':')) != NULL) { *collon = '\0'; -- cgit