env -i ./minishell auits and doesnt segfault. fixed behaviour for builtins in pipeline (fork zhen out isnt stdout)
This commit is contained in:
parent
07b8519239
commit
0188b7d012
11 changed files with 39 additions and 27 deletions
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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 */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@
|
|||
/* ::: :::::::: */
|
||||
/* lexer.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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 */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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 */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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 */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@
|
|||
/* ::: :::::::: */
|
||||
/* parser.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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 */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 579520046d5c025368da365a4f15c793d5a5ee13
|
||||
Subproject commit 1012e7bc51bb9b80cf9e62cacec4e61a6a37507d
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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++;
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@
|
|||
/* ::: :::::::: */
|
||||
/* ft_interactive_sh.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* lib_tc.c :+: :+: :+: */
|
||||
/* ft_set_termios.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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 */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue