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:
Tanguy MAZE
2019-01-16 17:30:11 +01:00
parent d21269c7ef
commit dcc7d43dd9
3 changed files with 76 additions and 53 deletions

View File

@@ -6,7 +6,7 @@
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/11/18 13:09:55 by tmaze #+# #+# */
/* Updated: 2019/01/13 16:59:24 by tmaze ### ########.fr */
/* Updated: 2019/01/16 17:06:51 by tmaze ### ########.fr */
/* */
/* ************************************************************************** */
@@ -106,28 +106,32 @@ int main(void)
ft_putstr("$> ");
ft_putstr(FT_RESET);
ret = get_next_line(1, &cmd);
if (ret == -1)
if (cmd != NULL && ft_strlen(cmd) != 0)
{
ft_lstdel(&lst_env, &ft_lstdelenvelem);
if (ret == -1)
{
ft_lstdel(&lst_env, &ft_lstdelenvelem);
ft_strdel(&cmd);
return (2);
}
if (ft_strcmp("exit", cmd) == 0)
{
ft_lstdel(&lst_env, &ft_lstdelenvelem);
ft_strdel(&cmd);
return (0);
}
else if ((tab_cmd = ft_strsplit(cmd, ' ')) == NULL)
{
ft_lstdel(&lst_env, &ft_lstdelenvelem);
ft_strdel(&cmd);
ft_putendl("error split");
return (2);
}
ft_strdel(&cmd);
return (2);
}
if (ft_strcmp("exit", cmd) == 0)
{
ft_lstdel(&lst_env, &ft_lstdelenvelem);
ft_strdel(&cmd);
return (0);
}
else if ((tab_cmd = ft_strsplit(cmd, ' ')) == NULL)
{
ft_lstdel(&lst_env, &ft_lstdelenvelem);
ft_strdel(&cmd);
ft_putendl("error split");
return (2);
exec_cmd(tab_cmd, &lst_env);
ft_del_words_tables(&tab_cmd);
}
ft_strdel(&cmd);
exec_cmd(tab_cmd, &lst_env);
ft_del_words_tables(&tab_cmd);
}
ft_lstdel(&lst_env, &ft_lstdelenvelem);
return (0);