From daaa9dea510447c01b2342b52897e7e7c65fdc17 Mon Sep 17 00:00:00 2001 From: Camille Chauvet Date: Fri, 17 Feb 2023 16:33:52 +0100 Subject: [PATCH] add: read input --- Makefile | 3 +- cmds.c | 2 +- execution.c | 6 +- heredoc.c | 15 ++- libftx/libft/ft_putchar_fd.c | 4 +- libftx/libft/ft_putendl_fd.c | 2 +- libftx/libft/libft.h | 4 +- libftx/libftx.h | 8 +- libftx/printf/ft_dprintarg.c | 6 +- libftx/printf/ft_dprintl_base.c | 4 +- libftx/printf/ft_dprintstrtab.c | 4 +- libftx/printf/ft_dprintul_base.c | 6 +- libftx/printf/ft_printf.h | 4 +- libftx/printf/ft_putchar_fd.c | 4 +- libftx/printf/ft_putstr_fd.c | 4 +- libftx/printf/ft_vdprintf.c | 4 +- main.c | 170 +++++++++++++++++++++---------- minishell.h | 4 +- t | 1 + 19 files changed, 167 insertions(+), 88 deletions(-) create mode 100644 t diff --git a/Makefile b/Makefile index ff84e10..a483424 100644 --- a/Makefile +++ b/Makefile @@ -28,7 +28,8 @@ fclean: clean make -C libftx fclean rm -f ${NAME} -re: fclean all +re: fclean + make all .PHONY: all clean fclean re diff --git a/cmds.c b/cmds.c index 037b60e..df201a1 100644 --- a/cmds.c +++ b/cmds.c @@ -6,7 +6,7 @@ /* By: cchauvet executable = ft_get_executable_path(content->executable, env); if (content->executable != NULL) ft_excutor(content, env); - close(content->fd_in); - close(content->fd_out); + if (content->fd_in != 0) + close(content->fd_in); + if (content->fd_out != 1 && content->fd_out != 2) + close(content->fd_out); current = current->next; } return (0); diff --git a/heredoc.c b/heredoc.c index 8b7f2e2..3b1634c 100644 --- a/heredoc.c +++ b/heredoc.c @@ -1,3 +1,16 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* heredoc.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cchauvet "); } diff --git a/libftx/libft/ft_putchar_fd.c b/libftx/libft/ft_putchar_fd.c index 5e34a25..1b06855 100644 --- a/libftx/libft/ft_putchar_fd.c +++ b/libftx/libft/ft_putchar_fd.c @@ -6,13 +6,13 @@ /* By: cchauvet base_size - 1) { ft_dprintul_base(fd, n / base_size, base); - ft_putchar_fd(fd, base[n % base_size]); + ft_putchar_fd_p(fd, base[n % base_size]); } else - ft_putchar_fd(fd, base[n]); + ft_putchar_fd_p(fd, base[n]); return (str_size - 1); } diff --git a/libftx/printf/ft_printf.h b/libftx/printf/ft_printf.h index 8f011a0..5ab4eb9 100644 --- a/libftx/printf/ft_printf.h +++ b/libftx/printf/ft_printf.h @@ -6,7 +6,7 @@ /* By: cchauvet # include # include - +# define DEBUG 0 t_list **init_env(char **env); int set_value_by_key(char *key, char *value, t_list **env); char *get_value_by_key(char *key, t_list **head); diff --git a/t b/t new file mode 100644 index 0000000..363df41 --- /dev/null +++ b/t @@ -0,0 +1 @@ +bozt