aboutsummaryrefslogtreecommitdiff
path: root/src/path.c
diff options
context:
space:
mode:
authorCharles Cabergs <me@cacharle.xyz>2020-10-09 09:16:17 +0200
committerCharles Cabergs <me@cacharle.xyz>2020-10-09 09:16:17 +0200
commit97e7e9b9934f99fbc659445512b19a525802726c (patch)
treec4d9f3aa6ce75b5c85758f69d82931b000269899 /src/path.c
parent7765a1e2c54759382312c4a611b24ae4f226e64f (diff)
downloadminishell-97e7e9b9934f99fbc659445512b19a525802726c.tar.gz
minishell-97e7e9b9934f99fbc659445512b19a525802726c.tar.bz2
minishell-97e7e9b9934f99fbc659445512b19a525802726c.zip
Fixing empty PATH variable bug
Diffstat (limited to 'src/path.c')
-rw-r--r--src/path.c11
1 files changed, 9 insertions, 2 deletions
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 <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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';