summaryrefslogtreecommitdiffstats
path: root/src/b_pwd.c
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-08-10 16:35:39 +0200
committerJozanLeClerc <bousset.rudy@gmail.com>2020-08-10 16:35:39 +0200
commit75304f8962129981b6198facafde8275db30ae66 (patch)
tree55587b38ba9375b5b40e916e9cc76a90777893f3 /src/b_pwd.c
parentTODO done (diff)
download42-minishell-75304f8962129981b6198facafde8275db30ae66.tar.gz
42-minishell-75304f8962129981b6198facafde8275db30ae66.tar.bz2
42-minishell-75304f8962129981b6198facafde8275db30ae66.tar.xz
42-minishell-75304f8962129981b6198facafde8275db30ae66.tar.zst
42-minishell-75304f8962129981b6198facafde8275db30ae66.zip
pwd TODO done
Diffstat (limited to 'src/b_pwd.c')
-rw-r--r--src/b_pwd.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/b_pwd.c b/src/b_pwd.c
index 2b87091..5e4209e 100644
--- a/src/b_pwd.c
+++ b/src/b_pwd.c
@@ -13,7 +13,9 @@
#include <libft.h>
#include <stdint.h>
#include <unistd.h>
+#include <errno.h>
+#include "f_fail.h"
#include "s_struct.h"
#include "u_vars.h"
#include "u_vars_next.h"
@@ -31,8 +33,8 @@ uint8_t
ft_memdel((void*)&cwd);
return (0);
}
- if ((cwd = u_get_var_value("$PWD", msh)) == NULL)
- cwd = getcwd(NULL, 0);
+ if ((cwd = ft_strdup(msh->cwd)) == NULL)
+ f_fail_alloc_and_destroy(msh);
ft_printf("%s\n", cwd);
ft_memdel((void*)&cwd);
return (0);