From 1fb76725c2b3e40c710cdc45ece34625e811aa23 Mon Sep 17 00:00:00 2001 From: Antoine Riard Date: Mon, 27 Mar 2017 18:53:33 +0200 Subject: [PATCH] no leaks env -bad option --- 42sh/src/builtin/builtin_env.c | 5 ++++- 42sh/src/lexer/get_state_global.c | 2 +- 42sh/src/lexer/lexer_bang.c | 5 +++-- 42sh/src/main/main.c | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/42sh/src/builtin/builtin_env.c b/42sh/src/builtin/builtin_env.c index 73c3f826..ad5da964 100644 --- a/42sh/src/builtin/builtin_env.c +++ b/42sh/src/builtin/builtin_env.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/22 16:20:31 by gwojda #+# #+# */ -/* Updated: 2017/03/25 20:40:41 by jhalford ### ########.fr */ +/* Updated: 2017/03/27 18:52:26 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -71,7 +71,10 @@ int builtin_env(const char *path, (void)envp; if (bt_env_parse(&dat, (char**)argv)) + { + ft_sstrfree(dat.custom_env); return (ft_perror("env") && SH_ERR("usage: %s", ENV_USAGE)); + } if (!*dat.av_data) return (display_env(dat.custom_env)); else if ((pid = fork()) == 0) diff --git a/42sh/src/lexer/get_state_global.c b/42sh/src/lexer/get_state_global.c index 12796d40..b741215b 100644 --- a/42sh/src/lexer/get_state_global.c +++ b/42sh/src/lexer/get_state_global.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/09 20:39:06 by jhalford #+# #+# */ -/* Updated: 2017/03/27 18:13:03 by jhalford ### ########.fr */ +/* Updated: 2017/03/27 18:39:55 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/lexer/lexer_bang.c b/42sh/src/lexer/lexer_bang.c index 14042405..9fc18aab 100644 --- a/42sh/src/lexer/lexer_bang.c +++ b/42sh/src/lexer/lexer_bang.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/27 18:12:03 by jhalford #+# #+# */ -/* Updated: 2017/03/27 18:18:55 by jhalford ### ########.fr */ +/* Updated: 2017/03/27 18:53:10 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -17,7 +17,8 @@ int lexer_bang(t_list **alst, t_lexer *lexer) t_token *token; token = (*alst)->content; - if (token->type) + if (!token->type || token->type == TK_SEMI || token->type == TK_NEWLINE + || token->type == TK_AMP) { token->type = TK_BANG; lexer->state = DEFAULT; diff --git a/42sh/src/main/main.c b/42sh/src/main/main.c index fb87ef7f..f07ed64f 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/27 18:08:20 by ariard ### ########.fr */ +/* Updated: 2017/03/27 18:28:37 by ariard ### ########.fr */ /* */ /* ************************************************************************** */