From 72bb124bced341ceb4548e0bd672b2ce8285b15f Mon Sep 17 00:00:00 2001 From: Jack Halford Date: Fri, 24 Mar 2017 15:13:01 +0100 Subject: [PATCH 1/5] close #179 --- 42sh/libft/includes/error.h | 4 ++-- 42sh/libft/src/cliopts/cliopts_get.c | 7 +++++-- 42sh/libft/src/error/error.c | 6 +++--- 42sh/src/builtin/builtin_env.c | 4 ++-- 42sh/src/builtin/builtin_export.c | 4 ++-- 42sh/src/builtin/builtin_read.c | 26 +++++++++++--------------- 42sh/src/job_control/builtin_jobs.c | 4 ++-- 42sh/src/lexer/get_state_global.c | 3 +-- 42sh/src/main/main.c | 4 ++-- 42sh/src/main/shell_init.c | 4 ++-- 10 files changed, 32 insertions(+), 34 deletions(-) diff --git a/42sh/libft/includes/error.h b/42sh/libft/includes/error.h index c9eb792b..896b5bcb 100644 --- a/42sh/libft/includes/error.h +++ b/42sh/libft/includes/error.h @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/14 15:34:21 by jhalford #+# #+# */ -/* Updated: 2017/03/21 14:05:04 by jhalford ### ########.fr */ +/* Updated: 2017/03/24 15:11:06 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -41,6 +41,6 @@ extern int g_errnum; extern char **g_argv; int error_set(int n, ...); -int ft_perror(void); +int ft_perror(char *utility); #endif diff --git a/42sh/libft/src/cliopts/cliopts_get.c b/42sh/libft/src/cliopts/cliopts_get.c index e2aa284d..0576d5df 100644 --- a/42sh/libft/src/cliopts/cliopts_get.c +++ b/42sh/libft/src/cliopts/cliopts_get.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/14 20:04:04 by jhalford #+# #+# */ -/* Updated: 2017/03/20 15:50:08 by jhalford ### ########.fr */ +/* Updated: 2017/03/24 15:02:26 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -97,7 +97,10 @@ int cliopts_get(char **av, t_cliopts opt_map[], void *data) while (av && *av) { if (ft_strcmp(*av, "--") == 0) - return (0); + { + av++; + break ; + } else if ((*av)[0] == '-' && (*av)[1] == '-') { if (cliopts_parse_long(&av, opt_map, data)) diff --git a/42sh/libft/src/error/error.c b/42sh/libft/src/error/error.c index 2c82901b..3bf7451d 100644 --- a/42sh/libft/src/error/error.c +++ b/42sh/libft/src/error/error.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/14 16:47:00 by jhalford #+# #+# */ -/* Updated: 2017/03/15 20:45:41 by jhalford ### ########.fr */ +/* Updated: 2017/03/24 15:10:44 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -37,8 +37,8 @@ int error_set(int n, ...) return (g_errnum); } -int ft_perror(void) +int ft_perror(char *utility) { - ft_dprintf(2, "{red}%s: %s{eoc}\n", g_argv[0], g_errmsg); + ft_dprintf(2, "{red}%s: %s{eoc}\n", utility ? utility : g_argv[0], g_errmsg); return (g_errnum); } diff --git a/42sh/src/builtin/builtin_env.c b/42sh/src/builtin/builtin_env.c index 08c29937..838a9c24 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/22 17:17:28 by jhalford ### ########.fr */ +/* Updated: 2017/03/24 15:11:42 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -55,7 +55,7 @@ int builtin_env(const char *path, (void)envp; if (bt_env_parse(&data, (char**)argv)) - return (ft_perror() && SH_ERR("usage: %s", ENV_USAGE) ? 0 : 0); + return (ft_perror("env") && SH_ERR("usage: %s", ENV_USAGE) ? 0 : 0); else if (!*data.av_data) return (builtin_setenv(NULL, (char*[]){"setenv", 0}, NULL)); else if ((pid = fork()) == 0) diff --git a/42sh/src/builtin/builtin_export.c b/42sh/src/builtin/builtin_export.c index 56e47007..444218b3 100644 --- a/42sh/src/builtin/builtin_export.c +++ b/42sh/src/builtin/builtin_export.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/15 11:39:37 by gwojda #+# #+# */ -/* Updated: 2017/03/20 14:44:02 by wescande ### ########.fr */ +/* Updated: 2017/03/24 15:11:48 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -45,7 +45,7 @@ int builtin_export( (void)path; data.flag = 0; if (cliopts_get((char**)av, g_export_opts, &data)) - ft_perror(); + ft_perror("export"); if (data.flag & BT_EXPORT_LP) return (bt_export_print()); av = data.av_data; diff --git a/42sh/src/builtin/builtin_read.c b/42sh/src/builtin/builtin_read.c index ce94d408..abea9035 100644 --- a/42sh/src/builtin/builtin_read.c +++ b/42sh/src/builtin/builtin_read.c @@ -6,14 +6,14 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/01/20 15:01:45 by jhalford #+# #+# */ -/* Updated: 2017/03/22 19:21:49 by jhalford ### ########.fr */ +/* Updated: 2017/03/24 15:10:57 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ #include "minishell.h" #define US_READ "read [-ers] [-u fd] [-t timeout] [-p prompt]" -#define US_READ_1 "[-n nchars] [-d delim] [name ...]" +#define US_READ_1 " [-n nchars] [-d delim] [name ...]" t_cliopts g_read_opts[] = { @@ -36,12 +36,12 @@ int bt_read_init(t_read *data, char **av) data->fd = 0; data->timeout = 0; data->input = NULL; - if ((cliopts_get(av, g_read_opts, data))) - return (ft_perror() ? 2 : 2); if (isatty(STDIN)) data->opts |= BT_READ_INTER; if (bt_read_terminit(data) < 0) - return (-1); + exit (1); + if ((cliopts_get(av, g_read_opts, data))) + return (ft_perror("read")); return (0); } @@ -89,7 +89,8 @@ int bt_read_assign(t_read *data) tok = ft_strtok(input, ifs); while (*names) { - builtin_setenv("setenv", (char*[]){"setenv", *names, tok}, NULL); + if (!(builtin_setenv("setenv", (char*[]){"read", *names, tok}, NULL))) + return (1); ifs = names[1] ? ifs : NULL; tok = ft_strtok(NULL, ifs); names++; @@ -106,16 +107,11 @@ int builtin_read(const char *path, char *const av[], char *const envp[]) (void)envp; ret = 0; if ((ret = bt_read_init(&data, (char **)av)) != 0) - ; + SH_ERR("usage: %s%s", US_READ, US_READ_1); else if ((ret = bt_read_loop(&data))) ; - else if (data.input && bt_read_assign(&data)) - ret = 1; - if (ret == -1) - exit(1); - if (ret != 0) - SH_ERR("usage: read %s %s\n", US_READ, US_READ_1); - if (ret != 2) - bt_read_exit(&data); + else if (data.input && (ret = bt_read_assign(&data))) + ; + bt_read_exit(&data); return (ret); } diff --git a/42sh/src/job_control/builtin_jobs.c b/42sh/src/job_control/builtin_jobs.c index 15f0e33a..1be75003 100644 --- a/42sh/src/job_control/builtin_jobs.c +++ b/42sh/src/job_control/builtin_jobs.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/15 17:43:01 by jhalford #+# #+# */ -/* Updated: 2017/03/24 14:08:12 by jhalford ### ########.fr */ +/* Updated: 2017/03/24 15:12:22 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -74,7 +74,7 @@ int builtin_jobs(const char *path, char *const av[], char *const envp[]) } ft_bzero(&data, sizeof(t_data_template)); if (cliopts_get((char**)av, g_jobs_opts, &data)) - return (ft_perror()); + return (ft_perror("jobs")); if (!*data.av_data) bt_jobs_all(data.flag); else if (bt_jobs_spec(data.av_data, data.flag)) diff --git a/42sh/src/lexer/get_state_global.c b/42sh/src/lexer/get_state_global.c index b3b1846c..aa08fe4e 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/24 14:20:30 by jhalford ### ########.fr */ +/* Updated: 2017/03/24 14:51:00 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -22,7 +22,6 @@ t_lexstate get_state_global(t_lexer *lexer) c = lexer->str[lexer->pos]; cn = lexer->str[lexer->pos + 1]; cl = lexer->pos ? lexer->str[lexer->pos - 1] : 0; - DG("%i : '%c'", lexer->pos, cl); ret = 0; if ((ft_is_delim(c) && (ret = DELIM)) || ((c == '&' || c == ';' || c == '|' || c == '!') && (ret = SEP)) diff --git a/42sh/src/main/main.c b/42sh/src/main/main.c index 2b2f966c..3c88c29a 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/23 16:58:43 by ariard ### ########.fr */ +/* Updated: 2017/03/24 14:42:13 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -45,7 +45,7 @@ static int handle_instruction(t_list **token, t_btree **ast) continue ; if ((ret = do_parser_routine(token, ast)) == 1 && SH_NO_INTERACTIVE(data->opts)) - return (ret); + return (ret); else if (ret > 0) break ; } diff --git a/42sh/src/main/shell_init.c b/42sh/src/main/shell_init.c index 4931fd36..16844a6f 100644 --- a/42sh/src/main/shell_init.c +++ b/42sh/src/main/shell_init.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/12 17:23:59 by jhalford #+# #+# */ -/* Updated: 2017/03/22 19:36:07 by jhalford ### ########.fr */ +/* Updated: 2017/03/24 15:12:31 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -89,7 +89,7 @@ int shell_init(int ac, char **av) return (-1); if (cliopts_get(av, g_opts, data)) { - ft_perror(); + ft_perror(NULL); return (SH_ERR("usage: %s", SHELL_USAGE)); } if (!isatty(STDIN) || *data->av_data) From b95476a0bef93c8fa1050df31dfecba7d19252ac Mon Sep 17 00:00:00 2001 From: Antoine Riard Date: Fri, 24 Mar 2017 15:18:17 +0100 Subject: [PATCH 2/5] error for + case fix close #174 --- 42sh/Makefile | 3 +-- 42sh/includes/exec.h | 4 +--- 42sh/sample/case/case.sh | 5 ++++- 42sh/src/exec/error_badidentifier.c | 21 --------------------- 42sh/src/exec/plaunch_for.c | 6 ++++-- 42sh/src/lexer/get_reserved_words.c | 3 ++- 42sh/src/lexer/isrw_delim.c | 2 +- 42sh/src/main/main.c | 3 ++- 42sh/src/parser/add_case.c | 8 ++++---- 42sh/src/parser/build_tree.c | 3 +-- 42sh/src/parser/ft_parse.c | 3 ++- 42sh/src/parser/tree_wrapper.c | 2 +- 12 files changed, 23 insertions(+), 40 deletions(-) delete mode 100644 42sh/src/exec/error_badidentifier.c diff --git a/42sh/Makefile b/42sh/Makefile index 5e78833d..5fddcd99 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/24 12:02:21 by gwojda ### ########.fr # +# Updated: 2017/03/24 14:53:07 by ariard ### ########.fr # # # # **************************************************************************** # @@ -65,7 +65,6 @@ completion/c_terminal.c\ completion/completion.c\ exec/ast_free.c\ exec/bad_fd.c\ -exec/error_badidentifier.c\ exec/exec_ampersand.c\ exec/exec_and_if.c\ exec/exec_bang.c\ diff --git a/42sh/includes/exec.h b/42sh/includes/exec.h index 92a89a05..2d24813b 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/23 16:27:10 by ariard ### ########.fr */ +/* Updated: 2017/03/24 14:47:12 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -166,8 +166,6 @@ void *redir_copy(void *data); void redir_free(void *data, size_t content_size); char **token_to_argv(t_ld *ld, int do_match); - -int error_badidentifier(char *name); t_btree *is_function(t_process *p); /* diff --git a/42sh/sample/case/case.sh b/42sh/sample/case/case.sh index f41470f9..14b13108 100644 --- a/42sh/sample/case/case.sh +++ b/42sh/sample/case/case.sh @@ -1,5 +1,8 @@ case van in ( "bus" ) echo Hello world ;; ( "velo" ) echo Comment va ;; - ( "van" ) ls ;; + ( "van" ) case tutu in + ( toto ) pwd ;; + ( tutu ) ls ;; + esac ;; esac diff --git a/42sh/src/exec/error_badidentifier.c b/42sh/src/exec/error_badidentifier.c deleted file mode 100644 index 9238d892..00000000 --- a/42sh/src/exec/error_badidentifier.c +++ /dev/null @@ -1,21 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* error_badidentifier.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: ariard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2017/03/06 18:03:51 by ariard #+# #+# */ -/* Updated: 2017/03/06 18:11:26 by ariard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "minishell.h" - -int error_badidentifier(char *name) -{ - ft_putstr_fd("`", 2); - ft_putstr(name); - ft_putstr_fd("' not a valid identifier", 2); - return (1); -} diff --git a/42sh/src/exec/plaunch_for.c b/42sh/src/exec/plaunch_for.c index bfaab55d..c5f97f8a 100644 --- a/42sh/src/exec/plaunch_for.c +++ b/42sh/src/exec/plaunch_for.c @@ -6,12 +6,14 @@ /* By: wescande +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/15 00:49:20 by wescande #+# #+# */ -/* Updated: 2017/03/22 22:20:02 by ariard ### ########.fr */ +/* Updated: 2017/03/24 14:52:00 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ #include "minishell.h" +#define FORERR_0 ": `%s' not a valid identifier" + int plaunch_for(t_process *p) { t_ld *temp; @@ -22,7 +24,7 @@ int plaunch_for(t_process *p) temp = p->data.d_for.token; var = ((char **)temp->content)[0]; if (!word_is_assignment(temp->content)) - return (error_badidentifier(var)); + return (SH_ERR(FORERR_0, var)); i = 0; av = token_to_argv(temp, 1); while (av[++i]) diff --git a/42sh/src/lexer/get_reserved_words.c b/42sh/src/lexer/get_reserved_words.c index 3426c33d..ed33e3ce 100644 --- a/42sh/src/lexer/get_reserved_words.c +++ b/42sh/src/lexer/get_reserved_words.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/01/26 00:07:05 by ariard #+# #+# */ -/* Updated: 2017/03/22 16:38:44 by gwojda ### ########.fr */ +/* Updated: 2017/03/24 15:01:55 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -39,6 +39,7 @@ static int recognization_rvwords(t_token *pv_tk, t_token *at_tk) || pv_tk->type == TK_ELIF || pv_tk->type == TK_ELSE || pv_tk->type == TK_DSEMI || pv_tk->type == TK_PAREN_OPEN || pv_tk->type == TK_LBRACE || pv_tk->type == TK_UNTIL) + || pv_tk->type == TK_PAREN_CLOSE || (pv_tk->type == TK_PAREN_CLOSE && at_tk->type == TK_PAREN_OPEN)); } diff --git a/42sh/src/lexer/isrw_delim.c b/42sh/src/lexer/isrw_delim.c index cede1c3d..5d9212a5 100644 --- a/42sh/src/lexer/isrw_delim.c +++ b/42sh/src/lexer/isrw_delim.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/20 19:12:50 by ariard #+# #+# */ -/* Updated: 2017/03/23 17:25:03 by ariard ### ########.fr */ +/* Updated: 2017/03/24 14:49:17 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/main/main.c b/42sh/src/main/main.c index 2b2f966c..0d3fa344 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/23 16:58:43 by ariard ### ########.fr */ +/* Updated: 2017/03/24 14:55:27 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -43,6 +43,7 @@ static int handle_instruction(t_list **token, t_btree **ast) return (ret); if (do_lexer_routine(token, stream) > 0) continue ; + token_print(*token); if ((ret = do_parser_routine(token, ast)) == 1 && SH_NO_INTERACTIVE(data->opts)) return (ret); diff --git a/42sh/src/parser/add_case.c b/42sh/src/parser/add_case.c index 42e864da..889b6142 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/22 15:30:25 by ariard ### ########.fr */ +/* Updated: 2017/03/24 15:17:40 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -62,12 +62,12 @@ int add_case_cmd(t_btree **ast, t_list **lst) node->nest++; if (token->type == TK_ESAC && (node->type == TK_PAREN_OPEN || node->type == TK_CASE) && node->nest > 0) - return ((node->nest--)); + node->nest--; else if (token->type == TK_DSEMI && node->type == TK_PAREN_OPEN && node->nest == 0) return ((node->full = 1)); - else if ((token->type == TK_ESAC) - && node->nest == 0) + else if ((token->type == TK_ESAC) && node->nest == 0 + && (node->type == TK_CASE || node->type == TK_PAREN_OPEN)) return ((node->full = 1)); else if (token->type == TK_PAREN_CLOSE) return (0); diff --git a/42sh/src/parser/build_tree.c b/42sh/src/parser/build_tree.c index afbb8fc4..7fee0309 100644 --- a/42sh/src/parser/build_tree.c +++ b/42sh/src/parser/build_tree.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/15 18:32:59 by ariard #+# #+# */ -/* Updated: 2017/03/23 16:49:18 by ariard ### ########.fr */ +/* Updated: 2017/03/24 15:01:36 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -84,7 +84,6 @@ int build_tree(t_btree **ast, t_list **lst) i = 0; token = (*lst)->content; check_cache(token, cache); - DG("new"); while (g_treematch[i].type) { if ((isseparator(token, cache) && g_treematch[i].type == token->type)) diff --git a/42sh/src/parser/ft_parse.c b/42sh/src/parser/ft_parse.c index 49426b09..a6845ec7 100644 --- a/42sh/src/parser/ft_parse.c +++ b/42sh/src/parser/ft_parse.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/11 16:17:38 by ariard #+# #+# */ -/* Updated: 2017/03/18 19:18:34 by ariard ### ########.fr */ +/* Updated: 2017/03/24 15:02:51 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -49,6 +49,7 @@ int ft_parse(t_btree **ast, t_list **token, t_parser *parser) parser->state = SUCCESS; else parser->state = UNDEFINED; + btree_print(STDBUG, *ast, &ft_putast); build_tree(ast, token); if ((end_instruction(&parser->stack) && !(*token)->next)) insert_linebreak(token); diff --git a/42sh/src/parser/tree_wrapper.c b/42sh/src/parser/tree_wrapper.c index 93622211..f056cdb8 100644 --- a/42sh/src/parser/tree_wrapper.c +++ b/42sh/src/parser/tree_wrapper.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/15 18:57:44 by ariard #+# #+# */ -/* Updated: 2017/03/21 15:46:51 by jhalford ### ########.fr */ +/* Updated: 2017/03/24 15:00:14 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ From 0bf28707da6f663262b02ac58673e7cb484dcdad Mon Sep 17 00:00:00 2001 From: Jack Halford Date: Fri, 24 Mar 2017 15:30:22 +0100 Subject: [PATCH 3/5] , --- 42sh/log | 63 -------------------------------------------- 42sh/src/main/main.c | 2 +- 2 files changed, 1 insertion(+), 64 deletions(-) delete mode 100644 42sh/log diff --git a/42sh/log b/42sh/log deleted file mode 100644 index 4bb9c0c4..00000000 --- a/42sh/log +++ /dev/null @@ -1,63 +0,0 @@ -env lvl 2 -env lvl 3 -env lvl 4 -env lvl 5 -env lvl 6 -env lvl 7 -env lvl 8 -env lvl 7 -env lvl 8 -env lvl 9 -env lvl 6 -env lvl 7 -env lvl 8 -env lvl 9 -env lvl 8 -env lvl 9 -env lvl 10 -env lvl 5 -env lvl 6 -env lvl 7 -env lvl 8 -env lvl 9 -env lvl 8 -env lvl 9 -env lvl 10 -env lvl 7 -env lvl 8 -env lvl 9 -env lvl 10 -env lvl 9 -env lvl 10 -env lvl 11 -env lvl 4 -env lvl 5 -env lvl 6 -env lvl 7 -env lvl 8 -env lvl 9 -env lvl 8 -env lvl 9 -env lvl 10 -env lvl 7 -env lvl 8 -env lvl 9 -env lvl 10 -env lvl 9 -env lvl 10 -env lvl 11 -env lvl 6 -env lvl 7 -env lvl 8 -env lvl 9 -env lvl 10 -env lvl 9 -env lvl 10 -env lvl 11 -env lvl 8 -env lvl 9 -env lvl 10 -env lvl 11 -env lvl 10 -env lvl 11 -env lvl 12 diff --git a/42sh/src/main/main.c b/42sh/src/main/main.c index cc84c2cc..e13db102 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/24 15:13:38 by jhalford ### ########.fr */ +/* Updated: 2017/03/24 15:26:50 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ From 1ba52fff84850b369cd98819a4e4aacac757a8a1 Mon Sep 17 00:00:00 2001 From: Jack Halford Date: Fri, 24 Mar 2017 15:41:30 +0100 Subject: [PATCH 4/5] close #172 --- 42sh/libft/src/error/error.c | 2 +- 42sh/src/job_control/builtin_jobs.c | 2 +- 42sh/src/job_control/job_hup_all.c | 7 ++++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/42sh/libft/src/error/error.c b/42sh/libft/src/error/error.c index 3bf7451d..4b743cea 100644 --- a/42sh/libft/src/error/error.c +++ b/42sh/libft/src/error/error.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/14 16:47:00 by jhalford #+# #+# */ -/* Updated: 2017/03/24 15:10:44 by jhalford ### ########.fr */ +/* Updated: 2017/03/24 15:36:34 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/job_control/builtin_jobs.c b/42sh/src/job_control/builtin_jobs.c index 1be75003..22ef92a6 100644 --- a/42sh/src/job_control/builtin_jobs.c +++ b/42sh/src/job_control/builtin_jobs.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/15 17:43:01 by jhalford #+# #+# */ -/* Updated: 2017/03/24 15:12:22 by jhalford ### ########.fr */ +/* Updated: 2017/03/24 15:39:48 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/job_control/job_hup_all.c b/42sh/src/job_control/job_hup_all.c index 37944153..0933048b 100644 --- a/42sh/src/job_control/job_hup_all.c +++ b/42sh/src/job_control/job_hup_all.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/20 11:37:40 by jhalford #+# #+# */ -/* Updated: 2017/03/20 20:51:54 by jhalford ### ########.fr */ +/* Updated: 2017/03/24 15:40:55 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -20,11 +20,16 @@ void job_hup_all(void) jobc = &data_singleton()->jobc; jlist = jobc->first_job; + if (!SH_HAS_JOBC(data_singleton()->opts)) + return ; while (jlist) { job = jlist->content; + DG("gonna SIGHUP %i", job->pgid); + builtin_jobs(NULL, NULL, NULL); if (job->pgid != 1) kill(-job->pgid, SIGHUP); + DG("after SIGHUP %i", job->pgid); jlist = jlist->next; } } From 9486317502fb3c77e4ca853fc9bfd4cc8f74ded1 Mon Sep 17 00:00:00 2001 From: gwojda Date: Fri, 24 Mar 2017 15:42:25 +0100 Subject: [PATCH 5/5] rip leaks --- 42sh/src/main/data_exit.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/42sh/src/main/data_exit.c b/42sh/src/main/data_exit.c index e0f79a5f..22861997 100644 --- a/42sh/src/main/data_exit.c +++ b/42sh/src/main/data_exit.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/07 18:07:50 by jhalford #+# #+# */ -/* Updated: 2017/03/24 12:40:41 by wescande ### ########.fr */ +/* Updated: 2017/03/24 15:42:05 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -17,6 +17,7 @@ void data_exit(void) t_data *data; data = data_singleton(); + ft_strdel(&data_singleton()->binary); ft_sstrfree(data->env); ft_sstrfree(data->local_var); ft_sstrfree(data->argv);