diff --git a/42sh/includes/exec.h b/42sh/includes/exec.h index 136d9db8..37d20604 100644 --- a/42sh/includes/exec.h +++ b/42sh/includes/exec.h @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/27 20:29:56 by jhalford #+# #+# */ -/* Updated: 2016/11/30 21:07:40 by jhalford ### ########.fr */ +/* Updated: 2016/11/30 22:47:18 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/includes/lexer.h b/42sh/includes/lexer.h index 73085b71..e4f40bae 100644 --- a/42sh/includes/lexer.h +++ b/42sh/includes/lexer.h @@ -3,10 +3,10 @@ /* ::: :::::::: */ /* lexer.h :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ +/* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/10 15:31:42 by jhalford #+# #+# */ -/* Updated: 2016/11/30 21:07:42 by jhalford ### ########.fr */ +/* Created: 2016/12/01 12:15:50 by jhalford #+# #+# */ +/* Updated: 2016/12/01 12:15:50 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/includes/line_editing.h b/42sh/includes/line_editing.h index 8ddd3bdc..2cad4345 100644 --- a/42sh/includes/line_editing.h +++ b/42sh/includes/line_editing.h @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/10 13:38:21 by jhalford #+# #+# */ -/* Updated: 2016/11/10 14:41:23 by jhalford ### ########.fr */ +/* Updated: 2016/12/01 12:13:57 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/includes/minishell.h b/42sh/includes/minishell.h index cc9214b5..6fdf1c2f 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: 2016/11/30 21:48:55 by jhalford ### ########.fr */ +/* Updated: 2016/12/01 12:13:46 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/includes/parser.h b/42sh/includes/parser.h index 6f93613c..09eb75fc 100644 --- a/42sh/includes/parser.h +++ b/42sh/includes/parser.h @@ -3,10 +3,10 @@ /* ::: :::::::: */ /* parser.h :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ +/* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/10 15:31:42 by jhalford #+# #+# */ -/* Updated: 2016/11/28 16:25:13 by jhalford ### ########.fr */ +/* Created: 2016/12/01 12:15:54 by jhalford #+# #+# */ +/* Updated: 2016/12/01 12:15:54 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/libft b/42sh/libft index 57952004..1012e7bc 160000 --- a/42sh/libft +++ b/42sh/libft @@ -1 +1 @@ -Subproject commit 579520046d5c025368da365a4f15c793d5a5ee13 +Subproject commit 1012e7bc51bb9b80cf9e62cacec4e61a6a37507d diff --git a/42sh/src/builtin/builtin.c b/42sh/src/builtin/builtin.c index c1f162bb..65fabb68 100644 --- a/42sh/src/builtin/builtin.c +++ b/42sh/src/builtin/builtin.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/28 14:21:34 by jhalford #+# #+# */ -/* Updated: 2016/11/29 19:45:25 by jhalford ### ########.fr */ +/* Updated: 2016/12/01 12:12:12 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -32,10 +32,20 @@ int ft_builtin(char **av, t_data *data) { if (ft_strcmp(g_builtin[i].name, *av) == 0) { - fd_redirect(data); - ret = (g_builtin[i].f)(av, data); - builtin_setenv((char*[3]){"?", ft_itoa(ret)}, data); - fd_reset(data); + if (data->fdout != STDOUT) + { + if (fork() == 0) + { + fd_redirect(data); + ret = (g_builtin[i].f)(av, data); + exit(ret); + } + } + else + { + ret = (g_builtin[i].f)(av, data); + builtin_setenv((char*[3]){"?", ft_itoa(ret)}, data); + } return (1); } i++; diff --git a/42sh/src/line-editing/ft_interactive_sh.c b/42sh/src/line-editing/ft_interactive_sh.c index d3c456d6..29f1a874 100644 --- a/42sh/src/line-editing/ft_interactive_sh.c +++ b/42sh/src/line-editing/ft_interactive_sh.c @@ -3,10 +3,10 @@ /* ::: :::::::: */ /* ft_interactive_sh.c :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ +/* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/10 13:44:21 by jhalford #+# #+# */ -/* Updated: 2016/11/29 15:32:42 by jhalford ### ########.fr */ +/* Created: 2016/12/01 12:14:12 by jhalford #+# #+# */ +/* Updated: 2016/12/01 12:29:32 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -56,7 +56,8 @@ int ft_interactive_sh(t_data *data) data->input_pos = 0; data->qstack = ft_lstnew(NULL, sizeof(t_qstate)); *((t_qstate*)data->qstack->content) = Q_NONE; - ft_set_termios(data, 1); + if (ft_set_termios(data, 1)) + return (-1); ft_prompt(); while (1) { diff --git a/42sh/src/line-editing/ft_set_termios.c b/42sh/src/line-editing/ft_set_termios.c index 56008f31..c59eefb8 100644 --- a/42sh/src/line-editing/ft_set_termios.c +++ b/42sh/src/line-editing/ft_set_termios.c @@ -1,12 +1,12 @@ /* ************************************************************************** */ /* */ /* ::: :::::::: */ -/* lib_tc.c :+: :+: :+: */ +/* ft_set_termios.c :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ +/* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/10 14:27:57 by jhalford #+# #+# */ -/* Updated: 2016/11/10 14:39:28 by jhalford ### ########.fr */ +/* Created: 2016/12/01 12:14:09 by jhalford #+# #+# */ +/* Updated: 2016/12/01 12:29:41 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -19,6 +19,7 @@ int ft_set_termios(t_data *data, int input_mode) if ((term_name = ft_getenv(data->env, "TERM")) == NULL) return (-1); + ft_debug(); if (tgetent(NULL, term_name) != 1) return (-1); if (tcgetattr(0, &term) == -1) diff --git a/42sh/src/main/data_init.c b/42sh/src/main/data_init.c index 83fa5658..7977737d 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: 2016/11/29 19:46:07 by jhalford ### ########.fr */ +/* Updated: 2016/12/01 12:12:59 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/main/main.c b/42sh/src/main/main.c index ee7018ff..58ee6142 100644 --- a/42sh/src/main/main.c +++ b/42sh/src/main/main.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/27 21:13:34 by jhalford #+# #+# */ -/* Updated: 2016/11/30 21:48:53 by jhalford ### ########.fr */ +/* Updated: 2016/12/01 12:28:47 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -41,8 +41,8 @@ int main(void) /* ft_dprintf(STDERR, "\n--- INFIX BREAKDOWN ---\n"); */ /* btree_apply_infix(ast, &ft_putast2); */ /* ft_lstdel(&token, &token_free); */ - /* if (ft_exec(ast, &data)) */ - /* return (1); */ + if (ft_exec(ast, &data)) + return (1); } return (0); }