summaryrefslogtreecommitdiffstats
path: root/src/b_pwd.c
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-08-04 17:54:15 +0200
committerJozanLeClerc <bousset.rudy@gmail.com>2020-08-04 17:54:15 +0200
commitf2924d712bfb49037763f232e0132d78334f4219 (patch)
treec184b2cd238c53b0293f29f69ed948931035ed59 /src/b_pwd.c
parentAdded -P to cwd (diff)
download42-minishell-f2924d712bfb49037763f232e0132d78334f4219.tar.gz
42-minishell-f2924d712bfb49037763f232e0132d78334f4219.tar.bz2
42-minishell-f2924d712bfb49037763f232e0132d78334f4219.tar.xz
42-minishell-f2924d712bfb49037763f232e0132d78334f4219.tar.zst
42-minishell-f2924d712bfb49037763f232e0132d78334f4219.zip
FeelsGoodMan
Diffstat (limited to 'src/b_pwd.c')
-rw-r--r--src/b_pwd.c15
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);
}