summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-04-23 20:39:56 +0200
committerJozanLeClerc <bousset.rudy@gmail.com>2020-04-23 20:39:56 +0200
commit15587099afed656c597eddec84e342831c00508f (patch)
treeb1799f588fcd8aff27c0320f3057ebf44da24ea1 /src
parentpwd is bav (diff)
download42-minishell-15587099afed656c597eddec84e342831c00508f.tar.gz
42-minishell-15587099afed656c597eddec84e342831c00508f.tar.bz2
42-minishell-15587099afed656c597eddec84e342831c00508f.tar.xz
42-minishell-15587099afed656c597eddec84e342831c00508f.tar.zst
42-minishell-15587099afed656c597eddec84e342831c00508f.zip
On the way
Diffstat (limited to '')
-rw-r--r--src/ft_b_cd.c12
-rw-r--r--src/ft_s_init.c2
-rw-r--r--src/ft_s_struct.h1
-rw-r--r--src/ft_u_utils.c18
-rw-r--r--src/ft_u_utils.h1
5 files changed, 33 insertions, 1 deletions
diff --git a/src/ft_b_cd.c b/src/ft_b_cd.c
index c0bf04b..eedb1c2 100644
--- a/src/ft_b_cd.c
+++ b/src/ft_b_cd.c
@@ -11,14 +11,24 @@
/* ************************************************************************** */
#include <stdint.h>
+#include <unistd.h>
+
#include "ft_s_struct.h"
+#include "ft_u_utils.h"
uint8_t
ft_b_cd(char *args[],
t_msh *msh)
{
- (void)args;
+ char *path;
+
(void)msh;
+ if (!args)
+ {
+ path = ft_get_home_dir(msh);
+ chdir();
+ ft_memdel((void*)&path);
+ }
/* TODO: do cd */
return (0);
}
diff --git a/src/ft_s_init.c b/src/ft_s_init.c
index 6c20c10..fb3ba6a 100644
--- a/src/ft_s_init.c
+++ b/src/ft_s_init.c
@@ -11,6 +11,7 @@
/* ************************************************************************** */
#include <libft.h>
+#include <stdlib.h>
#include <unistd.h>
#include "ft_d_define.h"
@@ -34,6 +35,7 @@ t_msh
ft_strlcpy(msh->ps_one, FT_PS_ONE, ft_strlen(FT_PS_ONE) + 1);
msh->cwd = NULL;
msh->cwd = getcwd(NULL, 0);
+ /* TODO: handle getcwd failed */
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 9386b5d..02e6e7f 100644
--- a/src/ft_s_struct.h
+++ b/src/ft_s_struct.h
@@ -14,6 +14,7 @@
#define FT_S_STRUCT_H
#include <stdint.h>
+
#include "ft_d_define.h"
/*
diff --git a/src/ft_u_utils.c b/src/ft_u_utils.c
index f5df2f4..8c61bf9 100644
--- a/src/ft_u_utils.c
+++ b/src/ft_u_utils.c
@@ -10,8 +10,26 @@
/* */
/* ************************************************************************** */
+#include <libft.h>
#include <stdint.h>
+#include "ft_s_struct.h"
+
+char
+ *ft_get_home_dir(t_msh *msh)
+{
+ char **ptr;
+
+ ptr = msh->envp;
+ while (*ptr)
+ {
+ if (ft_strncmp( , , ))
+ {
+ }
+ ptr++;
+ }
+}
+
uint64_t
ft_get_argc(const char *args[])
{
diff --git a/src/ft_u_utils.h b/src/ft_u_utils.h
index 1a3b324..84b2062 100644
--- a/src/ft_u_utils.h
+++ b/src/ft_u_utils.h
@@ -16,5 +16,6 @@
#include <stdint.h>
uint64_t ft_get_argc(const char *args[]);
+char *ft_get_home_dir(t_msh *msh);
#endif