From 9f073fc25c90974b408c75bf9a063538cb3cdefe Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Thu, 23 Apr 2020 20:31:21 +0200 Subject: pwd is bav --- src/ft_b_pwd.c | 5 +++-- src/ft_s_destroy.c | 1 + src/ft_s_init.c | 4 ++++ src/ft_s_struct.h | 3 ++- 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 #include + #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 +#include + #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*); -- cgit v1.2.3