WIP check path to launch executable
- able to launch ls from path - full user entry check (non existing exec, empty command..) still to do
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/01/07 16:44:40 by tmaze #+# #+# */
|
||||
/* Updated: 2019/01/13 17:00:19 by tmaze ### ########.fr */
|
||||
/* Updated: 2019/01/16 13:46:47 by tmaze ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -14,32 +14,7 @@
|
||||
|
||||
int cmd_cd(char **argv, t_list **env)
|
||||
{
|
||||
int i;
|
||||
int ret;
|
||||
char *path;
|
||||
t_list *tmp;
|
||||
|
||||
ret = 0;
|
||||
i = 0;
|
||||
tmp = *env;
|
||||
path = NULL;
|
||||
if (!argv[1])
|
||||
{
|
||||
while (tmp )
|
||||
{
|
||||
if (ft_strcmp(((t_envelem*)(tmp->content))->key, "HOME") == 0)
|
||||
{
|
||||
path = ((t_envelem*)(tmp->content))->val;
|
||||
break ;
|
||||
}
|
||||
tmp = tmp->next;
|
||||
}
|
||||
if (path == NULL)
|
||||
return (1);
|
||||
}
|
||||
else
|
||||
path = argv[1];
|
||||
ft_putendl(path);
|
||||
ret = chdir(path);
|
||||
return (ret);
|
||||
(void)argv;
|
||||
(void)env;
|
||||
return (0);
|
||||
}
|
||||
|
Reference in New Issue
Block a user