/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* cmd_unsetenv.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: tmaze +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/09/20 14:42:01 by tmaze #+# #+# */ /* Updated: 2019/10/17 10:58:23 by tmaze ### ########.fr */ /* */ /* ************************************************************************** */ #include "minishell.h" int cmd_unsetenv(char **argv, t_env **env) { 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); }