added unsetenv built-in + corrected looping Makefile

This commit is contained in:
Tanguy MAZE
2019-01-15 15:18:17 +01:00
parent 36d7fc342d
commit d21269c7ef
4 changed files with 31 additions and 9 deletions

21
srcs/cmd_unsetenv.c Normal file
View File

@@ -0,0 +1,21 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* cmd_unsetenv.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/01/15 14:58:05 by tmaze #+# #+# */
/* Updated: 2019/01/15 15:04:05 by tmaze ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
int cmd_unsetenv(char **argv, t_list **env)
{
if (argv[1] == NULL)
return (-1);
env_delelem(argv[1], env);
return (0);
}

View File

@@ -6,13 +6,13 @@
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/11/27 15:32:29 by tmaze #+# #+# */
/* Updated: 2019/01/13 17:02:33 by tmaze ### ########.fr */
/* Updated: 2019/01/15 15:11:22 by tmaze ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
#define S_BIN 4
#define S_BIN 5
char **envlsttotab(t_list *env)
{
@@ -53,8 +53,8 @@ int exec_cmd(char **argv, t_list **env)
char **env_tab;
size_t i;
static t_builtin builtins[S_BIN] = {{"echo", &cmd_echo},
{"cd", &cmd_cd}, {"env", &cmd_env},
{"setenv", &cmd_setenv}};
{"cd", &cmd_cd}, {"setenv", &cmd_setenv},
{"env", &cmd_env}, {"unsetenv", &cmd_unsetenv}};
i = 0;
while (i < S_BIN)