diff --git a/Makefile b/Makefile index d8a4d72..5ec5d12 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ # By: tmaze +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2018/11/22 14:43:33 by tmaze #+# #+# # -# Updated: 2019/01/13 17:03:41 by tmaze ### ########.fr # +# Updated: 2019/01/15 15:11:04 by tmaze ### ########.fr # # # #******************************************************************************# @@ -16,9 +16,9 @@ CCSTD := NAME := minishell -SRCS := main.c exec.c cmd_echo.c cmd_cd.c cmd_env.c cmd_setenv.c ms_env.c +SRCS := main.c exec.c cmd_echo.c cmd_cd.c cmd_env.c cmd_setenv.c cmd_unsetenv.c ms_env.c OBJS_DIR := objs -OBJS := $(addprefix $(OBJS_DIR)/, $(SRCS:.c=.o)) +OBJS := $(SRCS:.c=.o) INCLS := -Iincludes -Ilibft LIBS := -Llibft -lft @@ -29,7 +29,7 @@ all: $(NAME) $(NAME): $(OBJS) libft/libft.a $(CC) $(CCFLAGS) $(CCSTD) $(INCLS) $(OBJS) -o $(NAME) $(LIBS) -$(OBJS_DIR)/%.o: srcs/%.c includes/minishell.h $(OBJS_DIR) +%.o: srcs/%.c includes/minishell.h $(CC) $(CCFLAGS) $(CCSTD) $(INCLS) -c $< -o $@ $(OBJS_DIR): diff --git a/includes/minishell.h b/includes/minishell.h index 940a318..d41e38a 100644 --- a/includes/minishell.h +++ b/includes/minishell.h @@ -6,7 +6,7 @@ /* By: tmaze +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2018/11/18 13:12:34 by tmaze #+# #+# */ -/* Updated: 2019/01/13 17:03:08 by tmaze ### ########.fr */ +/* Updated: 2019/01/15 15:09:58 by tmaze ### ########.fr */ /* */ /* ************************************************************************** */ @@ -41,5 +41,6 @@ int cmd_echo(char **argv, t_list **env); int cmd_cd(char **argv, t_list **env); int cmd_env(char **argv, t_list **env); int cmd_setenv(char **argv, t_list **env); +int cmd_unsetenv(char **argv, t_list **env); #endif diff --git a/srcs/cmd_unsetenv.c b/srcs/cmd_unsetenv.c new file mode 100644 index 0000000..1679125 --- /dev/null +++ b/srcs/cmd_unsetenv.c @@ -0,0 +1,21 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* cmd_unsetenv.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: tmaze +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* 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); +} diff --git a/srcs/exec.c b/srcs/exec.c index 93d9e1f..b71f366 100644 --- a/srcs/exec.c +++ b/srcs/exec.c @@ -6,13 +6,13 @@ /* By: tmaze +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* 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)