corrected make'
This commit is contained in:
31
srcs/cmd_cd_utils.c
Normal file
31
srcs/cmd_cd_utils.c
Normal file
@@ -0,0 +1,31 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* cmd_cd_utils.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2020/02/14 11:55:54 by tmaze #+# #+# */
|
||||
/* Updated: 2020/02/14 11:56:53 by tmaze ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "minishell.h"
|
||||
|
||||
t_env *cd_updateenv(char *key, char *val, t_env **env)
|
||||
{
|
||||
t_env *tmp;
|
||||
|
||||
if ((tmp = ft_envgetelem(key, *env)) != NULL)
|
||||
ft_envupdate(key, *env, val);
|
||||
else if ((tmp = (t_env*)ft_memalloc(sizeof(t_env))) != NULL)
|
||||
{
|
||||
if ((tmp->key = ft_strdup(key)) == NULL)
|
||||
ft_envdelelem(&tmp);
|
||||
if (tmp && (tmp->val = ft_strdup(val)) == NULL)
|
||||
ft_envdelelem(&tmp);
|
||||
if (tmp)
|
||||
ft_envaddend(env, tmp);
|
||||
}
|
||||
return (tmp);
|
||||
}
|
Reference in New Issue
Block a user