From 7d4880b2b7097481774e59363ecb39d7d7181feb Mon Sep 17 00:00:00 2001 From: Jack Halford Date: Mon, 27 Mar 2017 19:42:49 +0200 Subject: [PATCH 1/2] :thumbsup: close #215 --- 42sh/src/exec/redirect_dless.c | 5 ++--- 42sh/src/main/shell_init.c | 3 ++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/42sh/src/exec/redirect_dless.c b/42sh/src/exec/redirect_dless.c index d8063a57..e204d3c3 100644 --- a/42sh/src/exec/redirect_dless.c +++ b/42sh/src/exec/redirect_dless.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/20 12:36:10 by jhalford #+# #+# */ -/* Updated: 2017/03/25 01:45:49 by jhalford ### ########.fr */ +/* Updated: 2017/03/27 19:41:50 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -21,7 +21,6 @@ int redirect_dless(t_redir *redir) str = redir->heredoc_data; write(fds[PIPE_WRITE], str, ft_strlen(str)); close(fds[PIPE_WRITE]); - dup2(fds[PIPE_READ], redir->n); - close(fds[PIPE_READ]); + fd_replace(fds[PIPE_READ], redir->n); return (0); } diff --git a/42sh/src/main/shell_init.c b/42sh/src/main/shell_init.c index 542f1780..bfd6768d 100644 --- a/42sh/src/main/shell_init.c +++ b/42sh/src/main/shell_init.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/12 17:23:59 by jhalford #+# #+# */ -/* Updated: 2017/03/27 18:08:56 by jhalford ### ########.fr */ +/* Updated: 2017/03/27 19:41:47 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -100,5 +100,6 @@ int shell_init(int ac, char **av, char **env) if (SH_IS_INTERACTIVE(data->opts) && interactive_settings() < 0) return (-1); shell_fds_init(); + shell_fds_push(); return (0); } From 047f289b67ae0fdf2b8c93f9e5d9f2126531a14e Mon Sep 17 00:00:00 2001 From: Jack Halford Date: Mon, 27 Mar 2017 19:51:28 +0200 Subject: [PATCH 2/2] norme --- 42sh/src/lexer/get_state_global.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/42sh/src/lexer/get_state_global.c b/42sh/src/lexer/get_state_global.c index b741215b..9c555d0e 100644 --- a/42sh/src/lexer/get_state_global.c +++ b/42sh/src/lexer/get_state_global.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/09 20:39:06 by jhalford #+# #+# */ -/* Updated: 2017/03/27 18:39:55 by ariard ### ########.fr */ +/* Updated: 2017/03/27 19:48:41 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -33,8 +33,7 @@ t_lexstate get_state_global(t_lexer *lexer) || ((c == '`') && (ret = BQUOTE)) || ((c == '(' || c == ')') && (ret = PAREN)) || (((c == '{' && (cn == ' ' || cn == 0)) - || (c == '}' && (cl == ' ' || cl == 0))) - && (ret = CURLY_BRACKETS)) + || (c == '}' && (cl == ' ' || cl == 0))) && (ret = CURLY_BRACKETS)) || ((c == 0) && (ret = END))) { ;