brace group execution done

This commit is contained in:
Jack Halford 2017-03-13 19:23:20 +01:00
parent 5b4a1c9a94
commit c167d80270
18 changed files with 79 additions and 23 deletions

View file

@ -82,6 +82,7 @@ exec/fd_is_valid.c\
exec/ft_exec.c\
exec/ft_findexec.c\
exec/is_function.c\
exec/launch_brace.c\
exec/launch_builtin.c\
exec/launch_case.c\
exec/launch_file.c\
@ -110,6 +111,7 @@ exec/redirect_less.c\
exec/redirect_lessand.c\
exec/set_exitstatus.c\
exec/set_process.c\
exec/set_process_brace.c\
exec/set_process_case.c\
exec/set_process_cmd.c\
exec/set_process_for.c\

View file

@ -1 +0,0 @@
cat: wefwewef: No such file or directory

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/27 20:29:56 by jhalford #+# #+# */
/* Updated: 2017/03/13 17:40:32 by jhalford ### ########.fr */
/* Updated: 2017/03/13 19:14:44 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -74,6 +74,7 @@ union u_process_data
{
struct s_data_cmd cmd;
struct s_data_subshell subshell;
struct s_data_subshell brace;
struct s_data_subshell function;
struct s_data_cond d_while;
struct s_data_cond d_until;
@ -88,6 +89,7 @@ enum e_process_type
PROCESS_BUILTIN,
PROCESS_FILE,
PROCESS_SUBSHELL,
PROCESS_BRACE,
PROCESS_WHILE,
PROCESS_UNTIL,
PROCESS_IF,
@ -187,6 +189,7 @@ int launch_case(t_process *p);
int launch_file(t_process *p);
int launch_builtin(t_process *p);
int launch_subshell(t_process *p);
int launch_brace(t_process *p);
int launch_function(t_process *p);
int launch_empty(t_process *p);

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/15 11:39:37 by gwojda #+# #+# */
/* Updated: 2017/03/13 18:01:19 by jhalford ### ########.fr */
/* Updated: 2017/03/13 19:00:58 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -19,11 +19,7 @@ int builtin_export(const char *path, char *const av[], char *const envp[])
if ((equal = ft_strchr(av[1], '=')))
{
*equal = 0;
return (builtin_setenv(path, (char*[]){"setenv", av[1], equal + 1}, envp));
builtin_setenv(path, (char*[]){"setenv", av[1], equal + 1}, envp);
}
else
{
// export doit chercher cette variable locale et la mettre dans l'env
return (0);
}
}

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/28 14:25:17 by jhalford #+# #+# */
/* Updated: 2017/03/13 18:01:08 by jhalford ### ########.fr */
/* Updated: 2017/03/13 18:10:37 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/07 15:47:30 by wescande #+# #+# */
/* Updated: 2017/03/13 17:40:29 by jhalford ### ########.fr */
/* Updated: 2017/03/13 19:06:45 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/27 20:30:32 by jhalford #+# #+# */
/* Updated: 2017/03/13 14:03:44 by jhalford ### ########.fr */
/* Updated: 2017/03/13 19:08:20 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -31,6 +31,7 @@ t_itof g_execmap[] =
{TK_ASSIGNEMENT_WORD, &exec_var},
{MATH, &exec_math},
{SUBSHELL, &exec_leaf},
{TK_LBRACE, &exec_leaf},
{TK_BANG, &exec_bang},
{CMD, &exec_leaf},
{0, 0},

View file

@ -0,0 +1,24 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* launch_brace.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/13 19:09:30 by jhalford #+# #+# */
/* Updated: 2017/03/13 19:21:39 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
int launch_brace(t_process *p)
{
if (process_redirect(p))
{
set_exitstatus(1, 1);
return (0);
}
ft_exec(&p->data.subshell.content);
return (0);
}

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/07 15:48:24 by jhalford #+# #+# */
/* Updated: 2017/03/11 18:16:25 by jhalford ### ########.fr */
/* Updated: 2017/03/13 19:15:13 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -19,7 +19,10 @@ int launch_builtin(t_process *p)
if (IS_PIPESINGLE(*p))
{
if (process_redirect(p))
{
set_exitstatus(1, 1);
return (0);
}
set_exitstatus((*p->data.cmd.execf)(p->data.cmd.path, p->data.cmd.av, data_singleton()->env), 1);
return (0);
}

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/13 14:20:45 by jhalford #+# #+# */
/* Updated: 2017/03/13 17:38:30 by jhalford ### ########.fr */
/* Updated: 2017/03/13 19:21:40 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -18,6 +18,7 @@ t_itof g_launchmap[] =
{PROCESS_BUILTIN, launch_builtin},
{PROCESS_FILE, launch_file},
{PROCESS_SUBSHELL, launch_subshell},
{PROCESS_BRACE, launch_brace},
{PROCESS_WHILE, launch_while},
{PROCESS_UNTIL, launch_until},
{PROCESS_IF, launch_if},

View file

@ -6,7 +6,7 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/08 00:11:44 by wescande #+# #+# */
/* Updated: 2017/03/13 13:27:48 by jhalford ### ########.fr */
/* Updated: 2017/03/13 19:12:26 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/06 22:09:53 by jhalford #+# #+# */
/* Updated: 2017/03/13 17:42:53 by jhalford ### ########.fr */
/* Updated: 2017/03/13 19:22:09 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/05 14:54:45 by jhalford #+# #+# */
/* Updated: 2017/03/13 17:38:56 by jhalford ### ########.fr */
/* Updated: 2017/03/13 19:06:50 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -0,0 +1,21 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* set_process_brace.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/13 19:07:34 by jhalford #+# #+# */
/* Updated: 2017/03/13 19:08:27 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
int set_process_brace(t_process *p, t_btree *ast)
{
p->data.subshell.content = btree_map(ast->right, &node_copy);
p->type = PROCESS_BRACE;
return (0);
}

View file

@ -6,7 +6,7 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/07 15:08:12 by wescande #+# #+# */
/* Updated: 2017/03/13 17:39:03 by jhalford ### ########.fr */
/* Updated: 2017/03/13 19:08:25 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -26,6 +26,7 @@ t_itof g_setprocessmap[] =
{MATH, NULL},
{SUBSHELL, &set_process_subshell},
{CMD, &set_process_cmd},
{TK_LBRACE, &set_process_subshell},
{0, NULL}
};

View file

@ -6,7 +6,7 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/08 00:02:01 by wescande #+# #+# */
/* Updated: 2017/03/08 14:59:55 by wescande ### ########.fr */
/* Updated: 2017/03/13 19:07:18 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/09 20:39:06 by jhalford #+# #+# */
/* Updated: 2017/03/07 19:33:58 by ariard ### ########.fr */
/* Updated: 2017/03/13 19:03:43 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -15,8 +15,12 @@
t_lexstate get_state_global(t_lexer *lexer)
{
char c;
char cn;
char cl;
c = lexer->str[lexer->pos];
cn = lexer->str[lexer->pos + 1];
cl = lexer->str[lexer->pos ? lexer->pos - 1 : 0];
if (ft_is_delim(c))
return (DELIM);
else if (c == '&' || c == ';' || c == '|' || c == '!')
@ -31,7 +35,8 @@ t_lexstate get_state_global(t_lexer *lexer)
return (BQUOTE);
else if (c == '(' || c == ')')
return (PAREN);
else if (c == '{' || c == '}')
else if ((c == '{' && cn == ' ')
|| (c == '}' && cl == ' '))
return (CURLY_BRACKETS);
else if (c == 0)
return (END);

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/17 16:39:05 by ariard #+# #+# */
/* Updated: 2017/03/13 16:59:01 by ariard ### ########.fr */
/* Updated: 2017/03/13 19:22:24 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -24,7 +24,7 @@ int isdir_sep(t_btree **ast, t_list **list)
if ((node->type == CMD || node->type == TK_IO_NUMBER
|| node->type == TK_WHILE || node->type == TK_IF
|| node->type == TK_FOR || node->type == SUBSHELL
|| node->type == TK_CASE || node->type == TK_RBRACE
|| node->type == TK_CASE || node->type == TK_LBRACE
|| node->type == TK_UNTIL)
&& (token->type == TK_LESS || token->type == TK_GREAT
|| token->type == TK_GREATAND || token->type == TK_LESSAND