moved env functions to libft
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/09/20 14:33:48 by tmaze #+# #+# */
|
||||
/* Updated: 2019/11/08 21:55:51 by tmaze ### ########.fr */
|
||||
/* Updated: 2019/12/09 09:59:58 by tmaze ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -39,6 +39,14 @@ t_env *envcpy(t_env *env)
|
||||
return (cpy);
|
||||
}
|
||||
|
||||
int env_cleanup(t_env *env_cp, int code)
|
||||
{
|
||||
ft_envdel(&env_cp);
|
||||
if (code == 2)
|
||||
ft_putstr_fd("minishell: env: Env copy error\n", 2);
|
||||
return (code);
|
||||
}
|
||||
|
||||
int cmd_env(char **argv, t_env **env)
|
||||
{
|
||||
int i;
|
||||
@@ -54,11 +62,7 @@ int cmd_env(char **argv, t_env **env)
|
||||
while (it)
|
||||
{
|
||||
if ((new = envcpy(it)) == NULL)
|
||||
{
|
||||
ft_envdel(&env_cp);
|
||||
ft_putstr_fd("minishell: env: Env copy error\n", 2);
|
||||
return (2);
|
||||
}
|
||||
return (env_cleanup(env_cp, 2));
|
||||
ft_envaddend(&env_cp, new);
|
||||
it = it->next;
|
||||
}
|
||||
@@ -69,6 +73,5 @@ int cmd_env(char **argv, t_env **env)
|
||||
exec_cmd(argv + i, &env_cp);
|
||||
else
|
||||
put_env(env_cp);
|
||||
ft_envdel(&env_cp);
|
||||
return (0);
|
||||
return (env_cleanup(env_cp, 0));
|
||||
}
|
||||
|
Reference in New Issue
Block a user