From 6f4ecd2960c1b0e30bbcc2ec53b29d56293dad11 Mon Sep 17 00:00:00 2001 From: Jack Halford Date: Fri, 17 Mar 2017 21:16:54 +0100 Subject: [PATCH] bquotes and '-c' work again --- 42sh/includes/minishell.h | 5 +++-- 42sh/src/line-editing/readline.c | 4 ++-- 42sh/src/main/data_init.c | 4 ++-- 42sh/src/main/shell_init.c | 6 +++--- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/42sh/includes/minishell.h b/42sh/includes/minishell.h index 7c408f3a..70d0c6d0 100644 --- a/42sh/includes/minishell.h +++ b/42sh/includes/minishell.h @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/10 13:07:44 by jhalford #+# #+# */ -/* Updated: 2017/03/17 20:52:27 by jhalford ### ########.fr */ +/* Updated: 2017/03/17 21:13:09 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -41,12 +41,13 @@ struct s_data { t_flag opts; + int fd; char **env; int argc; char **argv; t_line line; t_lexer lexer; - t_parser parser; + t_parser parser; t_comp *comp; t_exec exec; t_jobc jobc; diff --git a/42sh/src/line-editing/readline.c b/42sh/src/line-editing/readline.c index 0b84ab3d..8cf2a404 100644 --- a/42sh/src/line-editing/readline.c +++ b/42sh/src/line-editing/readline.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/15 14:19:48 by gwojda #+# #+# */ -/* Updated: 2017/03/17 16:10:40 by gwojda ### ########.fr */ +/* Updated: 2017/03/17 21:14:15 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -19,7 +19,7 @@ int readline(int has_prompt, char **input) if (!has_prompt) data_singleton()->line.prompt_size = 1; if (!SH_IS_INTERACTIVE(data_singleton()->opts)) - return ((ret = get_next_line(STDIN, input)) >= 0 ? !ret : ret); + return ((ret = get_next_line(data_singleton()->fd, input)) >= 0 ? !ret : ret); readline_init(has_prompt); ret = ft_read_stdin(input); if (ret < 0) diff --git a/42sh/src/main/data_init.c b/42sh/src/main/data_init.c index 77ac8219..71d87f6b 100644 --- a/42sh/src/main/data_init.c +++ b/42sh/src/main/data_init.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/28 19:26:32 by jhalford #+# #+# */ -/* Updated: 2017/03/17 20:51:06 by jhalford ### ########.fr */ +/* Updated: 2017/03/17 21:16:25 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -18,7 +18,7 @@ int data_init(int ac, char **av) { t_data *data; char *term_name; - char* shlvl; + char *shlvl; data = data_singleton(); data->argc = ac; diff --git a/42sh/src/main/shell_init.c b/42sh/src/main/shell_init.c index fbbf106b..28ee9e8d 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/16 23:25:29 by ariard ### ########.fr */ +/* Updated: 2017/03/17 21:16:24 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -33,11 +33,10 @@ int get_input_fd(char **av) else if (data->opts & SH_OPTS_LC) { pipe(fds); - dup2_close(fds[PIPE_READ], 10); - fd = 10; file = *cliopts_getdata(av); write(fds[PIPE_WRITE], file, ft_strlen(file)); close(fds[PIPE_WRITE]); + dup2_close(fds[PIPE_READ], (fd = 10)); fcntl(fd, F_SETFD, FD_CLOEXEC); return (fd); } @@ -93,6 +92,7 @@ int shell_init(int ac, char **av) } if (cliopts_get(av, g_opts, data)) return (ft_perror()); + data->fd = get_input_fd(av); if (SH_IS_INTERACTIVE(data->opts)) interactive_settings(); return (0);