diff options
Diffstat (limited to '')
-rw-r--r-- | src/ft_b_cd.c | 4 | ||||
-rw-r--r-- | src/ft_u_utils.c | 20 | ||||
-rw-r--r-- | src/ft_u_utils.h | 1 |
3 files changed, 3 insertions, 22 deletions
diff --git a/src/ft_b_cd.c b/src/ft_b_cd.c index cbb392a..7d4ef1a 100644 --- a/src/ft_b_cd.c +++ b/src/ft_b_cd.c @@ -16,6 +16,7 @@ #include "ft_s_struct.h" #include "ft_u_utils.h" +#include "ft_u_vars.h" /* static void */ /* ft_switch_env_var(char **envp) */ @@ -45,7 +46,8 @@ uint8_t if (argc == 0) { - path = ft_get_home_dir(msh->envp); + path = ft_subst_var_value("$HOME", msh); + ft_printf("%s\n", path); } if (chdir(path) != 0) { diff --git a/src/ft_u_utils.c b/src/ft_u_utils.c index 7e2eb53..b7ab7d8 100644 --- a/src/ft_u_utils.c +++ b/src/ft_u_utils.c @@ -26,23 +26,3 @@ uint64_t } return (argc); } - -char - *ft_get_home_dir(char **envp) -{ - char **ptr; - char *path; - - ptr = envp; - while (*ptr) - { - /* TODO: rework this correctly */ - if (ft_strncmp("HOME", *ptr, 4) == 0) - { - path = ft_substr(*ptr, 5, ft_strlen(*ptr + 5)); - return (path); - } - ptr++; - } - return (NULL); -} diff --git a/src/ft_u_utils.h b/src/ft_u_utils.h index d025cb2..1a3b324 100644 --- a/src/ft_u_utils.h +++ b/src/ft_u_utils.h @@ -16,6 +16,5 @@ #include <stdint.h> uint64_t ft_get_argc(const char *args[]); -char *ft_get_home_dir(char *envp[]); #endif |