&& || seem to work now

This commit is contained in:
Jack Halford 2017-03-05 15:19:18 +01:00
parent 566cd522ae
commit 9a038e9290
8 changed files with 18 additions and 11 deletions

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/27 20:29:56 by jhalford #+# #+# */
/* Updated: 2017/03/05 15:04:49 by jhalford ### ########.fr */
/* Updated: 2017/03/05 15:14:25 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -41,7 +41,7 @@
# define EXEC_IS_BG(j) (j & EXEC_BG)
# define EXEC_IS_FG(j) (!EXEC_IS_BG(j))
# define EXEC_IS_AND_IF(j) (j & EXEC_AND_IF)
# define EXEC_IS_OR_IF(j) (j & EXEC_JOB_OR_IF)
# define EXEC_IS_OR_IF(j) (j & EXEC_OR_IF)
# define EXEC_AOL_MASK (EXEC_AND_IF | EXEC_OR_IF)
# define EXEC_IS_IF_BRANCH(j) (j & EXEC_IF_BRANCH)

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/30 20:52:28 by jhalford #+# #+# */
/* Updated: 2017/03/03 16:05:42 by jhalford ### ########.fr */
/* Updated: 2017/03/05 15:18:41 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -20,6 +20,7 @@ int exec_and_if(t_btree **ast)
exec = &data_singleton()->exec;
push(&exec->op_stack, TK_AND_IF);
ft_exec(&(*ast)->left);
exec->attrs &= ~EXEC_OR_IF;
exec->attrs |= EXEC_AND_IF;
ft_exec(&(*ast)->right);

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/14 17:28:14 by jhalford #+# #+# */
/* Updated: 2017/03/05 15:03:35 by jhalford ### ########.fr */
/* Updated: 2017/03/05 15:14:10 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/06 18:07:31 by ariard #+# #+# */
/* Updated: 2017/03/04 17:37:11 by ariard ### ########.fr */
/* Updated: 2017/03/05 15:12:28 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/30 21:06:17 by jhalford #+# #+# */
/* Updated: 2017/03/03 16:07:35 by jhalford ### ########.fr */
/* Updated: 2017/03/05 15:18:49 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -20,7 +20,8 @@ int exec_or_if(t_btree **ast)
exec = &data_singleton()->exec;
push(&exec->op_stack, TK_OR_IF);
ft_exec(&(*ast)->left);
exec->attrs |= EXEC_OR_IF;
exec->attrs &= ~EXEC_AND_IF;
exec->attrs = EXEC_OR_IF;
ft_exec(&(*ast)->right);
/* data = data_singleton(); */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/05 14:54:45 by jhalford #+# #+# */
/* Updated: 2017/03/05 15:05:23 by jhalford ### ########.fr */
/* Updated: 2017/03/05 15:18:57 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -23,6 +23,11 @@ int set_process(t_process *p, t_btree *ast)
process_reset(p);
exec = &data_singleton()->exec;
op = pop(&exec->op_stack);
if ((EXEC_IS_AND_IF(exec->attrs)
&& ft_strcmp(ft_getenv(data_singleton()->env, "?"), "0") != 0)
|| (EXEC_IS_OR_IF(exec->attrs)
&& ft_strcmp(ft_getenv(data_singleton()->env, "?"), "0") == 0))
return (1);
if (!(p->av = token_to_argv(cmd->token, 1)))
return (1);
fds[PIPE_WRITE] = STDOUT;

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/13 13:54:51 by jhalford #+# #+# */
/* Updated: 2017/03/05 15:05:21 by jhalford ### ########.fr */
/* Updated: 2017/03/05 15:12:31 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/06 18:40:58 by jhalford #+# #+# */
/* Updated: 2017/03/04 19:29:28 by ariard ### ########.fr */
/* Updated: 2017/03/05 15:16:12 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -62,7 +62,7 @@ int handle_instruction(int fd)
error_syntax(&token, &parser, &ast);
}
DG("Before execution:");
// btree_print(STDBUG, ast, &ft_putast);
btree_print(STDBUG, ast, &ft_putast);
if (ft_exec(&ast))
return (1);
instruction_free(&token, &parser, &ast);