summaryrefslogtreecommitdiffstats
path: root/src/e_externs_next.c
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-08-05 23:05:03 +0200
committerJozanLeClerc <bousset.rudy@gmail.com>2020-08-05 23:05:03 +0200
commitf7b13a353092017e37045344528c985172eafc3a (patch)
treec0bf8c6e8611cb72055f6a65634d1d0d35d6c4d8 /src/e_externs_next.c
parentNew utils functions (diff)
download42-minishell-f7b13a353092017e37045344528c985172eafc3a.tar.gz
42-minishell-f7b13a353092017e37045344528c985172eafc3a.tar.bz2
42-minishell-f7b13a353092017e37045344528c985172eafc3a.tar.xz
42-minishell-f7b13a353092017e37045344528c985172eafc3a.tar.zst
42-minishell-f7b13a353092017e37045344528c985172eafc3a.zip
Vars are fixed and finished
Diffstat (limited to 'src/e_externs_next.c')
-rw-r--r--src/e_externs_next.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/e_externs_next.c b/src/e_externs_next.c
index e33405c..bbd9d81 100644
--- a/src/e_externs_next.c
+++ b/src/e_externs_next.c
@@ -19,6 +19,7 @@
#include "s_destroy.h"
#include "s_lcom.h"
#include "s_struct.h"
+#include "u_utils.h"
static char
*get_fullpath(const char p_path[],
@@ -47,7 +48,6 @@ char
char *envpath[],
t_msh *msh)
{
- /* TODO: norme */
struct dirent *ent;
char **p_path;
char *fullpath;
@@ -78,18 +78,19 @@ char
char
**get_env_path(t_msh *msh)
{
- char **p_env;
+ size_t i;
+ char **env_dup;
char **envpath;
char *envline;
- p_env = msh->envp;
- while (*p_env && ft_strncmp("PATH", *p_env, 4) != 0)
- {
- p_env++;
- }
- if (*p_env == NULL)
+ env_dup = u_get_env_var_names(msh);
+ i = 0;
+ while (env_dup[i] && ft_strncmp("PATH", env_dup[i], 5) != 0)
+ i++;
+ if (env_dup[i] == NULL)
return (NULL);
- envline = ft_strchr(*p_env, '=');
+ ft_delwords(env_dup);
+ envline = ft_strchr(msh->envp[i], '=');
envline += 1;
if (*envline != '\0')
{