added unsetenv built-in + corrected looping Makefile
This commit is contained in:
parent
36d7fc342d
commit
d21269c7ef
8
Makefile
8
Makefile
@ -6,7 +6,7 @@
|
|||||||
# By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ #
|
# By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ #
|
||||||
# +#+#+#+#+#+ +#+ #
|
# +#+#+#+#+#+ +#+ #
|
||||||
# Created: 2018/11/22 14:43:33 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
|
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_DIR := objs
|
||||||
OBJS := $(addprefix $(OBJS_DIR)/, $(SRCS:.c=.o))
|
OBJS := $(SRCS:.c=.o)
|
||||||
INCLS := -Iincludes -Ilibft
|
INCLS := -Iincludes -Ilibft
|
||||||
LIBS := -Llibft -lft
|
LIBS := -Llibft -lft
|
||||||
|
|
||||||
@ -29,7 +29,7 @@ all: $(NAME)
|
|||||||
$(NAME): $(OBJS) libft/libft.a
|
$(NAME): $(OBJS) libft/libft.a
|
||||||
$(CC) $(CCFLAGS) $(CCSTD) $(INCLS) $(OBJS) -o $(NAME) $(LIBS)
|
$(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 $@
|
$(CC) $(CCFLAGS) $(CCSTD) $(INCLS) -c $< -o $@
|
||||||
|
|
||||||
$(OBJS_DIR):
|
$(OBJS_DIR):
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
|
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2018/11/18 13:12:34 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_cd(char **argv, t_list **env);
|
||||||
int cmd_env(char **argv, t_list **env);
|
int cmd_env(char **argv, t_list **env);
|
||||||
int cmd_setenv(char **argv, t_list **env);
|
int cmd_setenv(char **argv, t_list **env);
|
||||||
|
int cmd_unsetenv(char **argv, t_list **env);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
21
srcs/cmd_unsetenv.c
Normal file
21
srcs/cmd_unsetenv.c
Normal 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);
|
||||||
|
}
|
@ -6,13 +6,13 @@
|
|||||||
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
|
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2018/11/27 15:32:29 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"
|
#include "minishell.h"
|
||||||
|
|
||||||
#define S_BIN 4
|
#define S_BIN 5
|
||||||
|
|
||||||
char **envlsttotab(t_list *env)
|
char **envlsttotab(t_list *env)
|
||||||
{
|
{
|
||||||
@ -53,8 +53,8 @@ int exec_cmd(char **argv, t_list **env)
|
|||||||
char **env_tab;
|
char **env_tab;
|
||||||
size_t i;
|
size_t i;
|
||||||
static t_builtin builtins[S_BIN] = {{"echo", &cmd_echo},
|
static t_builtin builtins[S_BIN] = {{"echo", &cmd_echo},
|
||||||
{"cd", &cmd_cd}, {"env", &cmd_env},
|
{"cd", &cmd_cd}, {"setenv", &cmd_setenv},
|
||||||
{"setenv", &cmd_setenv}};
|
{"env", &cmd_env}, {"unsetenv", &cmd_unsetenv}};
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
while (i < S_BIN)
|
while (i < S_BIN)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user