feature: added env, setenv & unsetenv builtins

added -i option & command execution to env
added setenv & unsetenv builtins
This commit is contained in:
Tanguy Maze
2019-10-10 16:56:40 +02:00
parent 58459bc0c1
commit d22bc173f1
4 changed files with 156 additions and 78 deletions

View File

@@ -6,7 +6,7 @@
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/09/20 14:42:01 by tmaze #+# #+# */
/* Updated: 2019/09/26 15:27:17 by tmaze ### ########.fr */
/* Updated: 2019/10/10 16:05:56 by tmaze ### ########.fr */
/* */
/* ************************************************************************** */
@@ -14,7 +14,26 @@
int cmd_unsetenv(char** argv, t_env** env)
{
(void)argv;
(void)env;
return (0);
t_env **it;
t_env *tmp;
it = env;
if (!argv[1])
{
ft_printf("usage: unsetenv [KEY]\n");
return (1);
}
while (*it)
{
if (ft_strequ((*it)->key, argv[1]))
{
tmp = *it;
*it = tmp->next;
lstdelelem(&tmp);
return (0);
}
it = &((*it)->next);
}
ft_printf("Entry %s not found\n", argv[1]);
return (1);
}