diff --git a/Makefile b/Makefile index d9a88ef..0a19b58 100755 --- a/Makefile +++ b/Makefile @@ -3,8 +3,8 @@ LIBFT = libft.a SRCS = minishell.c lexer.c parser.c utils.c caller.c built-in.c env.c OBJS = ${SRCS:.c=.o} -//READLINE_INC = ~/.brew/opt/readline/include -//LIB = -L ~/.brew/lib -lreadline -L ~/.brew/lib -lhistory -L. -lft +#READLINE_INC = ~/.brew/opt/readline/include +#LIB = -L ~/.brew/lib -lreadline -L ~/.brew/lib -lhistory -L. -lft LIB = -lreadline -lhistory -L. -lft @@ -23,7 +23,7 @@ all: $(NAME) clean: rm -rf ${OBJS} -fclean: clean +fclean: clean ${MAKE} -C ./libft fclean rm -rf libft.a rm -rf ${NAME} diff --git a/minishell.c b/minishell.c index 9fa53c8..471cfe0 100644 --- a/minishell.c +++ b/minishell.c @@ -29,14 +29,12 @@ int caller(t_command *cmd) pid = fork(); if (!pid) { + if (cmd->fd[0]) + dup2(cmd->fd[0], STDIN_FILENO); + if (cmd->fd[1]) + dup2(cmd->fd[1], STDOUT_FILENO); if (command_call(cmd->argv) == -1) - { - if (cmd->fd[0]) - dup2(cmd->fd[0], STDIN_FILENO); - if (cmd->fd[1]) - dup2(cmd->fd[1], STDOUT_FILENO); exe(cmd->argv, cmd->envp); - } exit(1); } if (cmd->fd[1])