WIP added basic cd command

The command only works with `-`, absolut paths and empty arg
No option has been added
This commit is contained in:
Tanguy MAZE
2019-01-21 17:35:57 +01:00
parent 0dfcd409df
commit 9dc92563e3
3 changed files with 86 additions and 8 deletions

View File

@@ -6,7 +6,7 @@
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/11/27 15:32:29 by tmaze #+# #+# */
/* Updated: 2019/01/17 17:43:00 by tmaze ### ########.fr */
/* Updated: 2019/01/21 13:21:04 by tmaze ### ########.fr */
/* */
/* ************************************************************************** */
@@ -175,6 +175,8 @@ char *check_path(char *exec, t_list *env)
ft_strdel(&ret);
i++;
}
if (path_elems[i] == NULL)
put_error(exec, "command not found");
ft_del_words_tables(&path_elems);
return (ret);
}
@@ -202,14 +204,14 @@ int exec_cmd(char **argv, t_list **env)
if ((ret = fork()) == 0)
{
execve(path, argv, env_tab);
ft_putendl_fd("minishell: error", 2);
ft_putendl_fd("minishell: error", 1);
if (ft_strcmp(path, argv[0]) != 0)
ft_strdel(&path);
ft_del_words_tables(&env_tab);
exit(-1);
}
else if (ret == -1)
ft_putendl_fd("minishell: error", 2);
ft_putendl_fd("minishell: error", 1);
if (ret == -1)
return (-1);
waitpid(ret, NULL, 0);