minishell/srcs/cmd_setenv.c
Tanguy Maze d22bc173f1 feature: added env, setenv & unsetenv builtins
added -i option & command execution to env
added setenv & unsetenv builtins
2019-10-10 16:56:40 +02:00

31 lines
1.2 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* cmd_setenv.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/09/20 14:41:08 by tmaze #+# #+# */
/* Updated: 2019/10/10 14:31:47 by tmaze ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
int cmd_setenv(char** argv, t_env** env)
{
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);
}
}