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:41:08 by tmaze #+# #+# */
/* Updated: 2019/09/26 15:27:06 by tmaze ### ########.fr */
/* Updated: 2019/10/10 14:31:47 by tmaze ### ########.fr */
/* */
/* ************************************************************************** */
@@ -14,7 +14,17 @@
int cmd_setenv(char** argv, t_env** env)
{
(void)argv;
(void)env;
return (0);
t_env *new;
if (argv[1] && (new = lstnew(argv[1])) != NULL)
{
lstaddend(env, new);
return (0);
} else if (argv[1]) {
ft_printf("minishell: setenv: memory error\n");
return (2);
} else {
printf("usage: setenv [KEY]=[value]\n");
return (1);
}
}