diff --git a/42sh/Makefile b/42sh/Makefile index 67a33c25..f3adc478 100644 --- a/42sh/Makefile +++ b/42sh/Makefile @@ -6,7 +6,7 @@ # By: wescande +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2016/08/29 21:32:58 by wescande #+# #+# # -# Updated: 2017/03/28 07:54:25 by jhalford ### ########.fr # +# Updated: 2017/03/29 11:03:41 by gwojda ### ########.fr # # # # **************************************************************************** # diff --git a/42sh/includes/exec.h b/42sh/includes/exec.h index 6a07c386..f29b39ba 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/27 19:46:14 by jhalford ### ########.fr */ +/* Updated: 2017/03/29 11:03:30 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -135,7 +135,6 @@ struct s_exec int fdin; t_list *op_stack; char **case_pattern; - int control_count; }; int exec_init(t_exec *exec); diff --git a/42sh/src/builtin/builtin_cd.c b/42sh/src/builtin/builtin_cd.c index e9a26980..52ba258d 100644 --- a/42sh/src/builtin/builtin_cd.c +++ b/42sh/src/builtin/builtin_cd.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/25 18:20:42 by ariard #+# #+# */ -/* Updated: 2017/03/28 19:41:52 by wescande ### ########.fr */ +/* Updated: 2017/03/29 11:03:20 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/exec/plaunch_for.c b/42sh/src/exec/plaunch_for.c index c5f97f8a..f1f0ad27 100644 --- a/42sh/src/exec/plaunch_for.c +++ b/42sh/src/exec/plaunch_for.c @@ -6,7 +6,7 @@ /* By: wescande +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/15 00:49:20 by wescande #+# #+# */ -/* Updated: 2017/03/24 14:52:00 by ariard ### ########.fr */ +/* Updated: 2017/03/28 20:29:55 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -27,6 +27,7 @@ int plaunch_for(t_process *p) return (SH_ERR(FORERR_0, var)); i = 0; av = token_to_argv(temp, 1); + data_singleton()->exec.job.attrs &= ~JOB_BG; while (av[++i]) { builtin_setenv("setenv", (char*[]){"local", var, av[i], 0}, diff --git a/42sh/src/exec/plaunch_until.c b/42sh/src/exec/plaunch_until.c index dbe8e2fb..17529fc1 100644 --- a/42sh/src/exec/plaunch_until.c +++ b/42sh/src/exec/plaunch_until.c @@ -6,7 +6,7 @@ /* By: wescande +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/07 22:04:42 by wescande #+# #+# */ -/* Updated: 2017/03/22 19:22:56 by jhalford ### ########.fr */ +/* Updated: 2017/03/28 20:30:19 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -17,6 +17,7 @@ int plaunch_until(t_process *p) int ret; ret = 0; + data_singleton()->exec.job.attrs &= ~JOB_BG; ft_exec(&p->data.d_until.condition); while (ft_strcmp(ft_getenv(data_singleton()->env, "?"), "0")) { diff --git a/42sh/src/exec/plaunch_while.c b/42sh/src/exec/plaunch_while.c index d4631982..9caaa1bd 100644 --- a/42sh/src/exec/plaunch_while.c +++ b/42sh/src/exec/plaunch_while.c @@ -6,7 +6,7 @@ /* By: wescande +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/07 17:20:53 by wescande #+# #+# */ -/* Updated: 2017/03/24 22:43:37 by jhalford ### ########.fr */ +/* Updated: 2017/03/28 20:29:54 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -17,6 +17,7 @@ int plaunch_while(t_process *p) int ret; ret = 0; + data_singleton()->exec.job.attrs &= ~JOB_BG; ft_exec(&p->data.d_while.condition); while (!(ft_strcmp(ft_getenv(data_singleton()->env, "?"), "0"))) { diff --git a/42sh/src/exec/process_launch.c b/42sh/src/exec/process_launch.c index ca41fa95..7f59bd60 100644 --- a/42sh/src/exec/process_launch.c +++ b/42sh/src/exec/process_launch.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/13 22:21:19 by jhalford #+# #+# */ -/* Updated: 2017/03/28 16:13:56 by wescande ### ########.fr */ +/* Updated: 2017/03/29 11:03:08 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -39,8 +39,7 @@ int process_fork(t_process *p) int process_launch(t_process *p) { p->state = PROCESS_RUNNING; - if (!IS_PIPESINGLE(*p) - || p->type == PROCESS_FILE + if (!IS_PIPESINGLE(*p) || p->type == PROCESS_FILE || p->type == PROCESS_SUBSHELL) { p->pid = process_fork(p); diff --git a/42sh/src/hash_table/is_hash.c b/42sh/src/hash_table/is_hash.c index 5f808380..f237795f 100644 --- a/42sh/src/hash_table/is_hash.c +++ b/42sh/src/hash_table/is_hash.c @@ -12,6 +12,18 @@ #include "minishell.h" +static char *h_free_one(t_list **head, t_list *list, t_list *ref) +{ + if (!((*head)->next)) + ft_lstdelone(head, &ft_hash_free); + else + { + ref->next = list->next; + ft_lstdelone(&list, &ft_hash_free); + } + return (NULL); +} + char *ft_is_hash(char *cmd) { t_list *list; @@ -25,12 +37,9 @@ char *ft_is_hash(char *cmd) { if (!ft_strcmp(((t_hash *)list->content)->key, cmd)) { - if (access(((t_hash *)list->content)->path, X_OK)) - { - ref->next = list->next; - ft_lstdelone(&list, &ft_hash_free); - return (NULL); - } + if (access(((t_hash *)list->content)->path, + X_OK | F_OK) < 0) + return (h_free_one(&g_hash[id], list, ref)); return (ft_strdup(((t_hash *)list->content)->path)); } ref = list; diff --git a/42sh/src/lexer/lexer_dquote.c b/42sh/src/lexer/lexer_dquote.c index 922f1966..9f85136c 100644 --- a/42sh/src/lexer/lexer_dquote.c +++ b/42sh/src/lexer/lexer_dquote.c @@ -6,13 +6,19 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/28 18:36:58 by jhalford #+# #+# */ -/* Updated: 2017/03/28 15:46:22 by jhalford ### ########.fr */ +/* Updated: 2017/03/28 19:55:03 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ #include "minishell.h" -int lexer_dquote(t_list **alst, t_lexer *lexer) +static int is_spec_dquote_esc(char c) +{ + return (c == '"' || c == '$' || c == '`' + || c == '\\' || c == '!'); +} + +int lexer_dquote(t_list **alst, t_lexer *lexer) { t_token *token; @@ -25,10 +31,10 @@ int lexer_dquote(t_list **alst, t_lexer *lexer) { if (lexer->str[++lexer->pos] == 0) return (push(&lexer->stack, BACKSLASH) ? 0 : 0); - else if (lexer->str[lexer->pos] == '"') + else if (is_spec_dquote_esc(lexer->str[lexer->pos])) + token_append(token, lexer, 1, 1); + else if (--lexer->pos || 1) token_append(token, lexer, 1, 1); - else - --lexer->pos; } else if (lexer->str[lexer->pos] == '`' && (lexer->state = BQUOTE)) return (lexer_lex(alst, lexer)); diff --git a/42sh/src/main/main.c b/42sh/src/main/main.c index 30e1f656..ea928af2 100644 --- a/42sh/src/main/main.c +++ b/42sh/src/main/main.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/20 14:45:40 by gwojda #+# #+# */ -/* Updated: 2017/03/28 16:14:10 by wescande ### ########.fr */ +/* Updated: 2017/03/29 11:02:44 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/parser/heredoc_parser.c b/42sh/src/parser/heredoc_parser.c index af941529..d6dd9a05 100644 --- a/42sh/src/parser/heredoc_parser.c +++ b/42sh/src/parser/heredoc_parser.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/08 16:21:05 by ariard #+# #+# */ -/* Updated: 2017/03/18 19:15:41 by ariard ### ########.fr */ +/* Updated: 2017/03/28 23:21:22 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -32,7 +32,7 @@ int pop_heredoc(t_list **lst) if (!lst || !*lst) return (0); token = (*lst)->content; - if (token->type == HEREDOCDATA + if ((token->type == HEREDOCDATA || token->type == TK_NEWLINE) && data_singleton()->parser.heredoc_queue != NULL) { if (!(head = &data_singleton()->parser.heredoc_queue))