feature: add cd built-in

This commit is contained in:
Tanguy Maze
2019-11-10 21:45:56 +01:00
parent e89ccb64b2
commit 4123c5dca3
9 changed files with 253 additions and 83 deletions

View File

@@ -6,7 +6,7 @@
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/09/20 14:33:48 by tmaze #+# #+# */
/* Updated: 2019/10/17 10:07:21 by tmaze ### ########.fr */
/* Updated: 2019/11/08 21:55:51 by tmaze ### ########.fr */
/* */
/* ************************************************************************** */
@@ -35,7 +35,7 @@ t_env *envcpy(t_env *env)
if (env != NULL && (cpy = (t_env*)ft_memalloc(sizeof(t_env))) != NULL)
if ((cpy->key = ft_strdup(env->key)) == NULL
|| (cpy->val = ft_strdup(env->val)) == NULL)
lstdelelem(&cpy);
ft_envdelelem(&cpy);
return (cpy);
}
@@ -55,11 +55,11 @@ int cmd_env(char **argv, t_env **env)
{
if ((new = envcpy(it)) == NULL)
{
lstdel(&env_cp);
ft_envdel(&env_cp);
ft_putstr_fd("minishell: env: Env copy error\n", 2);
return (2);
}
lstaddend(&env_cp, new);
ft_envaddend(&env_cp, new);
it = it->next;
}
}
@@ -69,6 +69,6 @@ int cmd_env(char **argv, t_env **env)
exec_cmd(argv + i, &env_cp);
else
put_env(env_cp);
lstdel(&env_cp);
ft_envdel(&env_cp);
return (0);
}