From f2924d712bfb49037763f232e0132d78334f4219 Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Tue, 4 Aug 2020 17:54:15 +0200 Subject: FeelsGoodMan --- src/b_pwd.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src/b_pwd.c') 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 #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); } -- cgit v1.2.3