Browse Source

fix: pipe on built-ins

master
narnaud 3 years ago
parent
commit
0ec79cf679
  1. 6
      Makefile
  2. 10
      minishell.c

6
Makefile

@ -3,8 +3,8 @@ LIBFT = libft.a
SRCS = minishell.c lexer.c parser.c utils.c caller.c built-in.c env.c SRCS = minishell.c lexer.c parser.c utils.c caller.c built-in.c env.c
OBJS = ${SRCS:.c=.o} OBJS = ${SRCS:.c=.o}
//READLINE_INC = ~/.brew/opt/readline/include #READLINE_INC = ~/.brew/opt/readline/include
//LIB = -L ~/.brew/lib -lreadline -L ~/.brew/lib -lhistory -L. -lft #LIB = -L ~/.brew/lib -lreadline -L ~/.brew/lib -lhistory -L. -lft
LIB = -lreadline -lhistory -L. -lft LIB = -lreadline -lhistory -L. -lft
@ -23,7 +23,7 @@ all: $(NAME)
clean: clean:
rm -rf ${OBJS} rm -rf ${OBJS}
fclean: clean fclean: clean
${MAKE} -C ./libft fclean ${MAKE} -C ./libft fclean
rm -rf libft.a rm -rf libft.a
rm -rf ${NAME} rm -rf ${NAME}

10
minishell.c

@ -29,14 +29,12 @@ int caller(t_command *cmd)
pid = fork(); pid = fork();
if (!pid) 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 (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); exe(cmd->argv, cmd->envp);
}
exit(1); exit(1);
} }
if (cmd->fd[1]) if (cmd->fd[1])

Loading…
Cancel
Save