diff options
Diffstat (limited to '')
-rw-r--r-- | src/b_pwd.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/b_pwd.c b/src/b_pwd.c index ac8d7d0..2b87091 100644 --- a/src/b_pwd.c +++ b/src/b_pwd.c @@ -15,20 +15,25 @@ #include <unistd.h> #include "s_struct.h" +#include "u_vars.h" +#include "u_vars_next.h" uint8_t b_pwd(char *args[], t_msh *msh) { - char *tmp; + char *cwd; if (args[0] != NULL && ft_strncmp(args[0], "-P", 3) == 0) { - tmp = getcwd(NULL, 0); - ft_printf("%s\n", tmp); - ft_memdel((void*)&tmp); + cwd = getcwd(NULL, 0); + ft_printf("%s\n", cwd); + ft_memdel((void*)&cwd); return (0); } - ft_printf("%s\n", msh->cwd); + if ((cwd = u_get_var_value("$PWD", msh)) == NULL) + cwd = getcwd(NULL, 0); + ft_printf("%s\n", cwd); + ft_memdel((void*)&cwd); return (0); } |