feature: add cd built-in
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/09/26 16:25:00 by tmaze #+# #+# */
|
||||
/* Updated: 2019/10/18 14:22:23 by tmaze ### ########.fr */
|
||||
/* Updated: 2019/11/10 15:52:54 by tmaze ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -62,7 +62,7 @@ char *check_path_dot(char *exec, t_env *env)
|
||||
char *tmp;
|
||||
char *ret;
|
||||
|
||||
if ((path = lstgetelem("PWD", env)) == NULL
|
||||
if ((path = ft_envgetelem("PWD", env)) == NULL
|
||||
|| path->val == NULL || (tmp = ft_strjoin(path->val, "/")) == NULL)
|
||||
{
|
||||
put_error(exec, "memory error");
|
||||
@@ -101,7 +101,7 @@ char *check_path(char *exec, t_env *env)
|
||||
return (check_path_slash(exec));
|
||||
if (exec[0] == '.')
|
||||
return (check_path_dot(exec, env));
|
||||
if ((path = lstgetelem("PATH", env)) == NULL
|
||||
if ((path = ft_envgetelem("PATH", env)) == NULL
|
||||
|| path->val == NULL
|
||||
|| (path_elems = ft_strsplit(path->val, ':')) == NULL)
|
||||
{
|
||||
@@ -147,7 +147,7 @@ int exec_cmd(char **argv, t_env **env)
|
||||
char **env_tab;
|
||||
char *path;
|
||||
|
||||
if ((env_tab = lsttotab(*env)) == NULL)
|
||||
if ((env_tab = ft_envtotab(*env)) == NULL)
|
||||
return (-1);
|
||||
if ((path = check_path(argv[0], *env)) == NULL)
|
||||
ft_del_words_tables(&env_tab);
|
||||
@@ -161,7 +161,7 @@ int exec_cmd(char **argv, t_env **env)
|
||||
if (ft_strcmp(path, argv[0]) != 0)
|
||||
ft_strdel(&path);
|
||||
ft_del_words_tables(&env_tab);
|
||||
lstdel(env);
|
||||
ft_envdel(env);
|
||||
exit(-1);
|
||||
}
|
||||
else if (ret == -1)
|
||||
|
||||
Reference in New Issue
Block a user