merge master

This commit is contained in:
gwojda 2017-03-29 11:03:51 +02:00
commit dab8c9ce53
11 changed files with 40 additions and 24 deletions

View file

@ -6,7 +6,7 @@
# By: wescande <wescande@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# 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 #
# #
# **************************************************************************** #

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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);

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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 */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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},

View file

@ -6,7 +6,7 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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"))
{

View file

@ -6,7 +6,7 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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")))
{

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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);

View file

@ -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;

View file

@ -6,13 +6,19 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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));

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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 */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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))