summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-08-04 16:24:56 +0200
committerJozanLeClerc <bousset.rudy@gmail.com>2020-08-04 16:24:56 +0200
commit22f7eda94424071edcfa6bb08eea6795adaf060b (patch)
tree8954042a6fa355983b80f0f8d2d51a3bf1805cc7 /src
parentFreed leak (diff)
download42-minishell-22f7eda94424071edcfa6bb08eea6795adaf060b.tar.gz
42-minishell-22f7eda94424071edcfa6bb08eea6795adaf060b.tar.bz2
42-minishell-22f7eda94424071edcfa6bb08eea6795adaf060b.tar.xz
42-minishell-22f7eda94424071edcfa6bb08eea6795adaf060b.tar.zst
42-minishell-22f7eda94424071edcfa6bb08eea6795adaf060b.zip
Added -P to cwd
Diffstat (limited to 'src')
-rw-r--r--src/b_pwd.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/b_pwd.c b/src/b_pwd.c
index 78ef128..ac8d7d0 100644
--- a/src/b_pwd.c
+++ b/src/b_pwd.c
@@ -12,6 +12,7 @@
#include <libft.h>
#include <stdint.h>
+#include <unistd.h>
#include "s_struct.h"
@@ -19,7 +20,15 @@ uint8_t
b_pwd(char *args[],
t_msh *msh)
{
- (void)args;
+ char *tmp;
+
+ if (args[0] != NULL && ft_strncmp(args[0], "-P", 3) == 0)
+ {
+ tmp = getcwd(NULL, 0);
+ ft_printf("%s\n", tmp);
+ ft_memdel((void*)&tmp);
+ return (0);
+ }
ft_printf("%s\n", msh->cwd);
return (0);
}