bug fix env -i && cd error message

This commit is contained in:
Tanguy MAZE
2020-02-14 12:22:35 +01:00
parent 7db099a010
commit b9c1a344b2
6 changed files with 31 additions and 10 deletions

View File

@@ -374,6 +374,7 @@ int ft_putendl_fd2(char const *s, int fd);
void ft_envdelelem(t_env **elem);
void ft_envdel(t_env **env);
t_env *ft_envnew(char *env);
t_env *ft_envnewinit(char *key, char *val, t_env *env);
t_env *ft_envaddend(t_env **alst, t_env *new);
t_env *ft_envgetelem(char *key, t_env *env);
char *ft_envtochar(t_env *env);

View File

@@ -27,3 +27,18 @@ t_env *ft_envnew(char *env)
ft_envdelelem(&ret);
return (ret);
}
t_env *ft_envnewinit(char *key, char *val, t_env *env)
{
t_env *ret;
int i;
i = 0;
ret = NULL;
if ((ret = (t_env*)ft_memalloc(sizeof(t_env))) != NULL)
if ((ret->key = ft_strdup(key)) != NULL)
if ((ret->val = ft_strdup(val)) != NULL)
return (ret);
ft_envdelelem(&ret);
return (ret);
}