diff --git a/42sh/Makefile b/42sh/Makefile index b9ffe23a..cfce41bd 100644 --- a/42sh/Makefile +++ b/42sh/Makefile @@ -78,6 +78,7 @@ exec/exec_semi.c\ exec/exec_until.c\ exec/exec_var.c\ exec/exec_while.c\ +exec/exec_math.c\ exec/fd_is_valid.c\ exec/ft_exec.c\ exec/ft_findexec.c\ diff --git a/42sh/includes/exec.h b/42sh/includes/exec.h index 4fc79d2b..849a1654 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: 2017/03/07 14:41:58 by wescande ### ########.fr */ +/* Updated: 2017/03/07 15:17:21 by wescande ### ########.fr */ /* */ /* ************************************************************************** */ @@ -16,19 +16,12 @@ # define PIPE_READ 0 # define PIPE_WRITE 1 -# define PROCESS_BUILTIN (1 << 0) -# define PROCESS_BINARY (1 << 1) -# define PROCESS_SCRIPT (1 << 2) -# define PROCESS_SUBSHELL (1 << 3) -# define PROCESS_UNKNOWN (1 << 4) -# define PROCESS_CONTROL (1 << 5) -# define PROCESS_COMPLETED (1 << 6) -# define PROCESS_SUSPENDED (1 << 7) -# define PROCESS_RUNNING (1 << 8) -# define PROCESS_CONTINUED (1 << 9) +# define PROCESS_COMPLETED (1 << 0) +# define PROCESS_SUSPENDED (1 << 1) +# define PROCESS_RUNNING (1 << 2) +# define PROCESS_CONTINUED (1 << 3) -# define PROCESS_TYPE_MASK (1 << 0 | 1 << 1 | 1 << 2 | 1 << 3 | 1 << 4 | 1 << 5) -# define PROCESS_STATE_MASK (1 << 6 | 1 << 7 | 1 << 8 | 1 << 9) +# define PROCESS_STATE_MASK ((1 << 4) - (1 << 0)) # define IS_PIPESTART(p) ((p).fdin == STDIN) # define IS_PIPEEND(p) ((p).fdout == STDOUT) @@ -39,18 +32,20 @@ # define EXEC_OR_IF (1 << 3) # define EXEC_IF_BRANCH (1 << 4) # define EXEC_CASE_BRANCH (1 << 5) + +# define EXEC_AOL_MASK (EXEC_AND_IF | EXEC_OR_IF) + # 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_OR_IF) -# define EXEC_AOL_MASK (EXEC_AND_IF | EXEC_OR_IF) - # define EXEC_IS_IF_BRANCH(j) (j & EXEC_IF_BRANCH) # define EXEC_IS_CASE_BRANCH(j) (j & EXEC_CASE_BRANCH) # include "../libft/includes/libft.h" # include "types.h" # include "job_control.h" +# include "minishell.h" struct s_data_cmd { @@ -83,32 +78,34 @@ union u_process_data // struct s_data_cond case; }; -typedef union u_process_data t_pdata; +enum e_process_type +{ + PROCESS_FUNCTION, + PROCESS_BUILTIN, + PROCESS_FILE, + PROCESS_SUBSHELL, + PROCESS_WHILE, + PROCESS_IF, + PROCESS_FOR, + PROCESS_CASE, +}; + +typedef enum e_process_type t_process_type; +typedef union u_process_data t_process_data; typedef struct s_data_cond t_data_while; typedef struct s_data_cond t_data_if; + struct s_process { - //normal_cmd -// char **av; -// char *path; -// t_execf *execf; - //while, if, elif .... -// t_btree *condition; -// t_btree *content; - //for => utilisation du av et du content -// char **av; -// t_btree *content; - - - t_pdata data; - - pid_t pid; - int fdin; - int fdout; - int to_close; - t_list *redirs; - int status; - t_flag attrs; + t_process_type type; + t_process_data data; + pid_t pid; + int fdin; + int fdout; + int to_close; + t_list *redirs; + int status; + t_flag attrs; }; struct s_exec @@ -122,22 +119,10 @@ struct s_exec int control_count; }; -struct s_execmap -{ - t_type type; - int (*f)(t_btree **ast); -}; -struct s_redirmap -{ - t_flag type; - int (*f)(t_redir *redir); -}; - -#include "minishell.h" - -extern t_execmap g_execmap[]; -extern t_redirmap g_redirmap[]; +extern t_itof g_execmap[]; +extern t_itof g_redirmap[]; +extern t_itof g_launchmap[]; int ft_exec(t_btree **ast); @@ -161,6 +146,7 @@ int exec_var(t_btree **ast); int exec_for(t_btree **ast); int exec_case(t_btree **ast); int exec_case_branch(t_btree **ast); +int exec_math(t_btree **ast); int launch_process(t_process *p); int set_process(t_process *p, t_btree *ast); @@ -171,7 +157,7 @@ void process_free(void *content, size_t content_size); void process_reset(t_process *p); void process_resetfds(void); -int fd_is_valid(int fd); +int fd_is_valid(int fd, int flag); int bad_fd(int fd); int process_redirect(t_process *p); int redirect_great(t_redir *redir); diff --git a/42sh/includes/minishell.h b/42sh/includes/minishell.h index 59e15890..7fab094a 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/04 16:46:52 by ariard ### ########.fr */ +/* Updated: 2017/03/07 14:27:40 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/includes/types.h b/42sh/includes/types.h index 2af27fa4..792363f9 100644 --- a/42sh/includes/types.h +++ b/42sh/includes/types.h @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/13 17:11:48 by jhalford #+# #+# */ -/* Updated: 2017/03/06 17:51:59 by ariard ### ########.fr */ +/* Updated: 2017/03/07 15:08:17 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/libft b/42sh/libft index a966b8a2..bc489f86 160000 --- a/42sh/libft +++ b/42sh/libft @@ -1 +1 @@ -Subproject commit a966b8a20028daba5580237fa0b0b18e16208f1b +Subproject commit bc489f8664fdc24317c31b3069811f54b1178643 diff --git a/42sh/src/builtin/bt_read_get.c b/42sh/src/builtin/bt_read_get.c index 62700b5a..f2e70ab1 100644 --- a/42sh/src/builtin/bt_read_get.c +++ b/42sh/src/builtin/bt_read_get.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/01/21 18:00:03 by jhalford #+# #+# */ -/* Updated: 2017/02/03 15:58:41 by jhalford ### ########.fr */ +/* Updated: 2017/03/07 11:27:49 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/builtin/builtin_env.c b/42sh/src/builtin/builtin_env.c index 100cd236..9458300d 100644 --- a/42sh/src/builtin/builtin_env.c +++ b/42sh/src/builtin/builtin_env.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/28 14:14:20 by jhalford #+# #+# */ -/* Updated: 2017/03/03 16:07:30 by jhalford ### ########.fr */ +/* Updated: 2017/03/07 11:29:18 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/builtin/builtin_setenv.c b/42sh/src/builtin/builtin_setenv.c index 3c803bd5..d5d5f99f 100644 --- a/42sh/src/builtin/builtin_setenv.c +++ b/42sh/src/builtin/builtin_setenv.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/28 14:25:17 by jhalford #+# #+# */ -/* Updated: 2017/02/17 13:18:25 by gwojda ### ########.fr */ +/* Updated: 2017/03/07 11:28:05 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/builtin/is_builtin.c b/42sh/src/builtin/is_builtin.c index 9c1216f0..3a2ee82c 100644 --- a/42sh/src/builtin/is_builtin.c +++ b/42sh/src/builtin/is_builtin.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/13 13:09:57 by jhalford #+# #+# */ -/* Updated: 2017/03/07 14:39:17 by wescande ### ########.fr */ +/* Updated: 2017/03/07 15:17:32 by wescande ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/exec/exec_command.c b/42sh/src/exec/exec_command.c index 6a6d04be..1054cc05 100644 --- a/42sh/src/exec/exec_command.c +++ b/42sh/src/exec/exec_command.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/14 17:28:14 by jhalford #+# #+# */ -/* Updated: 2017/03/07 15:03:54 by wescande ### ########.fr */ +/* Updated: 2017/03/07 15:17:47 by wescande ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/exec/exec_math.c b/42sh/src/exec/exec_math.c new file mode 100644 index 00000000..e157ef4c --- /dev/null +++ b/42sh/src/exec/exec_math.c @@ -0,0 +1,77 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* exec_math.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: ariard +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2017/03/07 10:58:49 by ariard #+# #+# */ +/* Updated: 2017/03/07 13:42:11 by ariard ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "exec.h" + +static int get_math(char *stream, char **var, char **value, char **operator) +{ + char *temp; + + *var = ft_strduptr(stream, &ft_isalpha); + temp = ft_sstrstr(data_singleton()->env, *var); + if (temp) + { + temp += ft_strlenchr(temp, '=') + 1; + *value = ft_strdup(temp); + if (!(ft_stris(*value, &ft_isdigit))) + { + ft_strdel(value); + *value = ft_itoa(0); + } + } + else + *value = ft_itoa(0); + stream += ft_strlen(*var); + *operator = ft_strdup(stream); + return (0); +} + +static int do_math(char **value, char *operator) +{ + long ope1; + long ope2; + + ope1 = ft_atoi(*value); + if (operator[2]) + ope2 = ft_atoi(&operator[2]); + else + ope2 = 0; + if (operator[0] == '/' && ope2 == 0) + ope1 = 0; + else + { + ope1 = (operator[0] == '+') ? ope1 + ope2 : ope1; + ope1 = (operator[0] == '-') ? ope1 - ope2 : ope1; + ope1 = (operator[0] == '/') ? ope1 / ope2 : ope1; + ope1 = (operator[0] == '*') ? ope1 * ope2 : ope1; + ope1 = (operator[0] == '%') ? ope1 % ope2 : ope1; + } + ft_strdel(value); + *value = ft_itoa(ope1); + return (0); +} + +int exec_math(t_btree **ast) +{ + t_astnode *node; + char **av; + char *var; + char *value; + char *operator; + + node = (*ast)->item; + av = token_to_argv(node->data.cmd.wordlist, 1); + get_math(av[0], &var, &value, &operator); + do_math(&value, operator); + builtin_setenv("setenv", (char *[]){var, value, 0}, data_singleton()->local_var); + return (0); +} diff --git a/42sh/src/exec/exec_var.c b/42sh/src/exec/exec_var.c index 4eca2107..b01c2f39 100644 --- a/42sh/src/exec/exec_var.c +++ b/42sh/src/exec/exec_var.c @@ -1,12 +1,12 @@ /* ************************************************************************** */ /* */ /* ::: :::::::: */ -/* exec_while.c :+: :+: :+: */ +/* exec_var.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ -/* Created: 2017/01/30 17:33:53 by ariard #+# #+# */ -/* Updated: 2017/03/07 12:17:43 by wescande ### ########.fr */ +/* Created: 2017/03/07 11:12:05 by ariard #+# #+# */ +/* Updated: 2017/03/07 14:40:30 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -14,12 +14,9 @@ static int set_var(char *stream, char **var, char **value) { - (void)stream; - (void)var; - (void)value; -/* *var = ft_strdupchr(stream, '='); + *var = ft_strdupchr(stream, '='); stream += ft_strlenchr(stream, '=') + 1; - value = ft_strdup(stream);*/ + *value = ft_strdup(stream); return (0); } diff --git a/42sh/src/exec/fd_is_valid.c b/42sh/src/exec/fd_is_valid.c index d89e0f49..39fac840 100644 --- a/42sh/src/exec/fd_is_valid.c +++ b/42sh/src/exec/fd_is_valid.c @@ -6,13 +6,16 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/03 13:46:40 by jhalford #+# #+# */ -/* Updated: 2017/03/05 19:44:16 by jhalford ### ########.fr */ +/* Updated: 2017/03/06 16:58:38 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ #include "minishell.h" -int fd_is_valid(int fd) +int fd_is_valid(int fd, int has_flag) { - return (fcntl(fd, F_GETFD) != -1 || errno != EBADF); + int flags; + + flags = fcntl(fd, F_GETFD); + return ((flags != -1 || errno != EBADF) && flags & has_flag); } diff --git a/42sh/src/exec/ft_exec.c b/42sh/src/exec/ft_exec.c index cfb28bde..00043e4b 100644 --- a/42sh/src/exec/ft_exec.c +++ b/42sh/src/exec/ft_exec.c @@ -6,13 +6,13 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/27 20:30:32 by jhalford #+# #+# */ -/* Updated: 2017/03/07 14:33:06 by wescande ### ########.fr */ +/* Updated: 2017/03/07 15:18:27 by wescande ### ########.fr */ /* */ /* ************************************************************************** */ #include "exec.h" -t_execmap g_execmap[] = +t_itof g_execmap[] = { {TK_NEWLINE, &exec_semi}, {TK_SEMI, &exec_semi}, @@ -29,6 +29,7 @@ t_execmap g_execmap[] = {TK_CASE, &exec_case}, {TK_PAREN_OPEN, &exec_case_branch}, {TK_ASSIGNEMENT_WORD, &exec_var}, + {MATH, &exec_math}, /* {TK_SUBSHELL, &exec_}, */ {CMD, &exec_cmd}, {0, 0}, diff --git a/42sh/src/exec/launch_file.c b/42sh/src/exec/launch_file.c new file mode 100644 index 00000000..c482d419 --- /dev/null +++ b/42sh/src/exec/launch_file.c @@ -0,0 +1,59 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* launch_file.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: jhalford +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2017/03/07 14:53:31 by jhalford #+# #+# */ +/* Updated: 2017/03/07 14:54:18 by jhalford ### ########.fr */ +/* */ +/* ************************************************************************** */ + +int launch_file(t_process *p) +{ + int pid; + + if (p->attrs & PROCESS_BUILTIN && IS_PIPESINGLE(*p)) + { + if (process_redirect(p)) + return (1); + set_exitstatus((*p->execf)(p->path, p->av, data_singleton()->env), 1); + return (1); + } + p->attrs &= ~PROCESS_STATE_MASK; + p->attrs |= PROCESS_RUNNING; + if (p->attrs & (PROCESS_BINARY | PROCESS_SCRIPT) + && access(p->path, X_OK) == -1) + { + ft_dprintf(2, "{red}%s: permission denied: %s{eoc}\n", SHELL_NAME, p->av[0]); + set_exitstatus(126, 1); + return (1); + } + pid = fork(); + if (pid == 0) + { + if (p->attrs & PROCESS_UNKNOWN) + { + ft_dprintf(2, "{red}%s: command not found: %s{eoc}\n", SHELL_NAME, p->av[0]); + exit(127); + } + process_setgroup(p, 0); + process_setsig(); + if (process_redirect(p)) + exit (1); + if (p->attrs & PROCESS_BUILTIN) + exit((*p->execf)(p->path, p->av, data_singleton()->env)); + (*p->execf)(p->path, p->av, data_singleton()->env); + ft_dprintf(2, "{red}%s: internal execve error on %s{eoc}\n", SHELL_NAME, p->av[0]); + } + else if (pid > 0) + { + p->pid = pid; + process_setgroup(p, pid); + return (0); + } + else if (pid == -1) + ft_dprintf(2, "{red}%s: internal fork error{eoc}\n", SHELL_NAME); + return (1); +} diff --git a/42sh/src/exec/launch_process.c b/42sh/src/exec/launch_process.c index e3c006fc..6b3a1df0 100644 --- a/42sh/src/exec/launch_process.c +++ b/42sh/src/exec/launch_process.c @@ -6,59 +6,36 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/13 14:20:45 by jhalford #+# #+# */ -/* Updated: 2017/03/07 14:43:48 by wescande ### ########.fr */ +/* Updated: 2017/03/07 15:19:05 by wescande ### ########.fr */ /* */ /* ************************************************************************** */ #include "minishell.h" +t_itof g_launchmap[] = +{ + {PROCESS_FUNCTION, NULL}, + {PROCESS_BUILTIN, NULL}, + {PROCESS_FILE, launch_file}, + {PROCESS_SUBSHELL, NULL}, + {PROCESS_WHILE, NULL}, + {PROCESS_IF, NULL}, + {PROCESS_FOR, NULL}, + {PROCESS_CASE, NULL}, +}; + int launch_process(t_process *p) { - int pid; + int i; - /* DG("gonna launch [%s]", p->av[0]); */ - /* DG("fdin=[%i]", p->fdin); */ - /* DG("fdout=[%i]", p->fdout); */ - if (p->attrs & PROCESS_BUILTIN && IS_PIPESINGLE(*p)) + i = 0; + while (g_launchmap[i].type) { - if (process_redirect(p)) - return (1); - set_exitstatus((*p->data.cmd.execf)(p->data.cmd.path, p->data.cmd.av, data_singleton()->env), 1); - return (1); + if (p->type == g_launchmap[i].type) + if (!g_launchmap[i].f) + return (-1); + return ((*g_launchmap[i].f)(p)); + i++; } - p->attrs &= ~PROCESS_STATE_MASK; - p->attrs |= PROCESS_RUNNING; - if (p->attrs & (PROCESS_BINARY | PROCESS_SCRIPT) - && access(p->data.cmd.path, X_OK) == -1) - { - ft_dprintf(2, "{red}%s: permission denied: %s{eoc}\n", SHELL_NAME, p->data.cmd.av[0]); - set_exitstatus(126, 1); - return (1); - } - pid = fork(); - if (pid == 0) - { - if (p->attrs & PROCESS_UNKNOWN) - { - ft_dprintf(2, "{red}%s: command not found: %s{eoc}\n", SHELL_NAME, p->data.cmd.av[0]); - exit(127); - } - process_setgroup(p, 0); - process_setsig(); - if (process_redirect(p)) - exit (1); - if (p->attrs & PROCESS_BUILTIN) - exit((*p->data.cmd.execf)(p->data.cmd.path, p->data.cmd.av, data_singleton()->env)); - (*p->data.cmd.execf)(p->data.cmd.path, p->data.cmd.av, data_singleton()->env); - ft_dprintf(2, "{red}%s: internal execve error on %s{eoc}\n", SHELL_NAME, p->data.cmd.av[0]); - } - else if (pid > 0) - { - p->pid = pid; - process_setgroup(p, pid); - return (0); - } - else if (pid == -1) - ft_dprintf(2, "{red}%s: internal fork error{eoc}\n", SHELL_NAME); - return (1); + return (-1); } diff --git a/42sh/src/exec/process_setexec.c b/42sh/src/exec/process_setexec.c index 46f381c6..0ab8f264 100644 --- a/42sh/src/exec/process_setexec.c +++ b/42sh/src/exec/process_setexec.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/13 17:07:10 by jhalford #+# #+# */ -/* Updated: 2017/03/07 14:42:01 by wescande ### ########.fr */ +/* Updated: 2017/03/07 15:34:12 by wescande ### ########.fr */ /* */ /* ************************************************************************** */ @@ -15,23 +15,25 @@ int process_setexec(t_process *p) { p->data.cmd.path = NULL; + /* if ((p->execf = is_function(p))) */ + /* p->type = PROCESS_FUNCTION; */ if ((p->data.cmd.execf = is_builtin(p))) - p->attrs |= PROCESS_BUILTIN; - else if (ft_strchr(p->data.cmd.av[0], '/')) - { - p->data.cmd.execf = &execve; - p->attrs |= PROCESS_SCRIPT; - p->data.cmd.path = ft_strdup(p->data.cmd.av[0]); - } + p->type = PROCESS_BUILTIN; else if (ft_hash(p)) { p->data.cmd.execf = &execve; - p->attrs |= PROCESS_BINARY; + p->type = PROCESS_FILE; + } + else if (ft_strchr(p->data.cmd.av[0], '/')) + { + p->data.cmd.execf = &execve; + p->type = PROCESS_FILE; + p->data.cmd.path = ft_strdup(p->data.cmd.av[0]); } else { p->data.cmd.execf = NULL; - p->attrs |= PROCESS_UNKNOWN; +// p->attrs |= PROCESS_UNKNOWN; return (1); } return (0); diff --git a/42sh/src/exec/redirect_greatand.c b/42sh/src/exec/redirect_greatand.c index c210c647..002375e8 100644 --- a/42sh/src/exec/redirect_greatand.c +++ b/42sh/src/exec/redirect_greatand.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/06 22:12:31 by jhalford #+# #+# */ -/* Updated: 2017/03/05 19:44:10 by jhalford ### ########.fr */ +/* Updated: 2017/03/06 16:54:43 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -33,7 +33,7 @@ int redirect_greatand(t_redir *redir) return (0); if (fdold > 9) return (bad_fd(fdold)); - if (fd_is_valid(fdold)) + if (fd_is_valid(fdold, O_RDONLY)) dup2_close(fdold, fdnew); else return (bad_fd(fdold)); diff --git a/42sh/src/exec/redirect_lessand.c b/42sh/src/exec/redirect_lessand.c index 0c3b5982..bb9987d6 100644 --- a/42sh/src/exec/redirect_lessand.c +++ b/42sh/src/exec/redirect_lessand.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/06 22:11:18 by jhalford #+# #+# */ -/* Updated: 2017/03/05 19:43:42 by jhalford ### ########.fr */ +/* Updated: 2017/03/06 16:53:29 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -33,7 +33,7 @@ int redirect_lessand(t_redir *redir) return (0); if (fdold > 9) return (bad_fd(fdold)); - if (fd_is_valid(fdold)) + if (fd_is_valid(fdold, O_WRONLY)) dup2_close(fdold, fdnew); else return (bad_fd(fdold)); diff --git a/42sh/src/exec/set_process.c b/42sh/src/exec/set_process.c index 8dedbcb0..b99307ed 100644 --- a/42sh/src/exec/set_process.c +++ b/42sh/src/exec/set_process.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/05 14:54:45 by jhalford #+# #+# */ -/* Updated: 2017/03/07 15:07:44 by wescande ### ########.fr */ +/* Updated: 2017/03/07 15:34:31 by wescande ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/hash_table/ft_add_hash.c b/42sh/src/hash_table/ft_add_hash.c index 659d126d..f97ead44 100644 --- a/42sh/src/hash_table/ft_add_hash.c +++ b/42sh/src/hash_table/ft_add_hash.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/18 11:20:11 by gwojda #+# #+# */ -/* Updated: 2017/03/07 14:44:52 by wescande ### ########.fr */ +/* Updated: 2017/03/07 15:34:57 by wescande ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/main/main.c b/42sh/src/main/main.c index 79ddbe24..cf6c3dcc 100644 --- a/42sh/src/main/main.c +++ b/42sh/src/main/main.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/06 18:40:58 by jhalford #+# #+# */ -/* Updated: 2017/03/06 17:58:39 by ariard ### ########.fr */ +/* Updated: 2017/03/07 15:09:53 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/main/shell_get_opts.c b/42sh/src/main/shell_get_opts.c index 0eee3eb4..dc75dddd 100644 --- a/42sh/src/main/shell_get_opts.c +++ b/42sh/src/main/shell_get_opts.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/01/11 14:04:48 by jhalford #+# #+# */ -/* Updated: 2017/03/05 17:45:37 by jhalford ### ########.fr */ +/* Updated: 2017/03/06 16:52:34 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/parser/add_case.c b/42sh/src/parser/add_case.c index f5862cef..4b4d5415 100644 --- a/42sh/src/parser/add_case.c +++ b/42sh/src/parser/add_case.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/04 20:42:13 by ariard #+# #+# */ -/* Updated: 2017/03/06 19:36:37 by ariard ### ########.fr */ +/* Updated: 2017/03/07 11:52:45 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -90,6 +90,7 @@ int add_pattern(t_btree **ast, t_list **lst) t_token *token; char **my_tab; + DG("add pattern"); token = (*lst)->content; node = (*ast)->item; if ((my_tab = (char **)malloc(sizeof(char *) * 4))) diff --git a/42sh/src/parser/add_func.c b/42sh/src/parser/add_func.c index ab3e0ae2..cc481f37 100644 --- a/42sh/src/parser/add_func.c +++ b/42sh/src/parser/add_func.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/24 23:43:07 by ariard #+# #+# */ -/* Updated: 2017/03/03 14:27:25 by ariard ### ########.fr */ +/* Updated: 2017/03/07 10:49:15 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -88,7 +88,7 @@ int add_one_func(t_btree **ast, t_list **lst) t_btree *func_ast; (void)lst; - func_ast = btree_map(*ast, &id); +// func_ast = btree_map(*ast, &id); ft_lsteadd(&data_singleton()->lst_func, ft_lstnew(&func_ast, sizeof(*ast))); DG("arbre ajoute"); return (0); diff --git a/42sh/src/parser/add_var.c b/42sh/src/parser/add_var.c index ad11bf54..661446b4 100644 --- a/42sh/src/parser/add_var.c +++ b/42sh/src/parser/add_var.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/03 15:08:16 by ariard #+# #+# */ -/* Updated: 2017/03/03 16:17:27 by ariard ### ########.fr */ +/* Updated: 2017/03/07 14:40:21 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/parser/eval_sym.c b/42sh/src/parser/eval_sym.c index d9a3de5c..dddb3261 100644 --- a/42sh/src/parser/eval_sym.c +++ b/42sh/src/parser/eval_sym.c @@ -188,7 +188,7 @@ t_stackmatch g_stackmatch[] = {TK_GREATAND, NEWLINE_LIST}, {TK_GREATAND, PIPE_SEMI_SEQUENCE}, {TK_GREATAND, SEQUENCE}, -// watch ! +// watch ! {TK_GREATAND, CMD_SUPERIOR}, {TK_GREATAND, AND_OR_MAJOR}, diff --git a/42sh/src/parser/produce_sym.c b/42sh/src/parser/produce_sym.c index 754f1205..868c0117 100644 --- a/42sh/src/parser/produce_sym.c +++ b/42sh/src/parser/produce_sym.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/09 17:58:34 by ariard #+# #+# */ -/* Updated: 2017/03/06 16:43:10 by ariard ### ########.fr */ +/* Updated: 2017/03/07 15:09:59 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */