summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-04-23 20:31:21 +0200
committerJozanLeClerc <bousset.rudy@gmail.com>2020-04-23 20:31:21 +0200
commit9f073fc25c90974b408c75bf9a063538cb3cdefe (patch)
treeac01185f1a4068698f0309481c3786f65e261489 /src
parent< redir works (diff)
download42-minishell-9f073fc25c90974b408c75bf9a063538cb3cdefe.tar.gz
42-minishell-9f073fc25c90974b408c75bf9a063538cb3cdefe.tar.bz2
42-minishell-9f073fc25c90974b408c75bf9a063538cb3cdefe.tar.xz
42-minishell-9f073fc25c90974b408c75bf9a063538cb3cdefe.tar.zst
42-minishell-9f073fc25c90974b408c75bf9a063538cb3cdefe.zip
pwd is bav
Diffstat (limited to 'src')
-rw-r--r--src/ft_b_pwd.c5
-rw-r--r--src/ft_s_destroy.c1
-rw-r--r--src/ft_s_init.c4
-rw-r--r--src/ft_s_struct.h3
4 files changed, 10 insertions, 3 deletions
diff --git a/src/ft_b_pwd.c b/src/ft_b_pwd.c
index f06a320..d47600f 100644
--- a/src/ft_b_pwd.c
+++ b/src/ft_b_pwd.c
@@ -10,7 +10,9 @@
/* */
/* ************************************************************************** */
+#include <libft.h>
#include <stdint.h>
+
#include "ft_s_struct.h"
uint8_t
@@ -18,7 +20,6 @@ uint8_t
t_msh *msh)
{
(void)args;
- (void)msh;
- /* TODO: do pwd */
+ ft_printf("%s\n", msh->cwd);
return (0);
}
diff --git a/src/ft_s_destroy.c b/src/ft_s_destroy.c
index 8d93250..7f495c4 100644
--- a/src/ft_s_destroy.c
+++ b/src/ft_s_destroy.c
@@ -17,6 +17,7 @@ void
ft_s_destroy(t_msh *msh)
{
ft_memdel((void*)&msh->ps_one);
+ ft_memdel((void*)&msh->cwd);
ft_delwords(msh->bu_ref);
ft_memdel((void*)&msh);
}
diff --git a/src/ft_s_init.c b/src/ft_s_init.c
index 63856c2..6c20c10 100644
--- a/src/ft_s_init.c
+++ b/src/ft_s_init.c
@@ -11,6 +11,8 @@
/* ************************************************************************** */
#include <libft.h>
+#include <unistd.h>
+
#include "ft_d_define.h"
#include "ft_m_funptr.h"
#include "ft_s_init.h"
@@ -30,6 +32,8 @@ t_msh
return (NULL);
}
ft_strlcpy(msh->ps_one, FT_PS_ONE, ft_strlen(FT_PS_ONE) + 1);
+ msh->cwd = NULL;
+ msh->cwd = getcwd(NULL, 0);
msh->envp = envp;
msh->ret = 0;
ft_init_buptr(msh);
diff --git a/src/ft_s_struct.h b/src/ft_s_struct.h
index 6a9b0ad..9386b5d 100644
--- a/src/ft_s_struct.h
+++ b/src/ft_s_struct.h
@@ -36,8 +36,9 @@ typedef struct s_lcom
typedef struct s_msh
{
- char *ps_one;
char **envp;
+ char *ps_one;
+ char *cwd;
uint8_t ret;
char **bu_ref;
uint8_t (*bu_ptr[FT_BUILTINS_COUNT])(char **, struct s_msh*);