From 0bf28707da6f663262b02ac58673e7cb484dcdad Mon Sep 17 00:00:00 2001 From: Jack Halford Date: Fri, 24 Mar 2017 15:30:22 +0100 Subject: [PATCH 01/10] , --- 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 02/10] 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 03/10] 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); From 26bddc8a58617f7a724dab699743312c673d2e3a Mon Sep 17 00:00:00 2001 From: wescande Date: Fri, 24 Mar 2017 15:54:09 +0100 Subject: [PATCH 04/10] ajout free des func + ajout builtin func --- 42sh/Makefile | 1 + 42sh/includes/builtin.h | 3 ++- 42sh/src/builtin/builtin_func.c | 46 +++++++++++++++++++++++++++++++++ 42sh/src/builtin/is_builtin.c | 3 ++- 42sh/src/main/data_exit.c | 4 ++- 5 files changed, 54 insertions(+), 3 deletions(-) create mode 100644 42sh/src/builtin/builtin_func.c diff --git a/42sh/Makefile b/42sh/Makefile index 5e78833d..4f3a2381 100644 --- a/42sh/Makefile +++ b/42sh/Makefile @@ -36,6 +36,7 @@ builtin/builtin_echo.c\ builtin/builtin_env.c\ builtin/builtin_exit.c\ builtin/builtin_export.c\ +builtin/builtin_func.c\ builtin/builtin_hash.c\ builtin/builtin_history.c\ builtin/builtin_math.c\ diff --git a/42sh/includes/builtin.h b/42sh/includes/builtin.h index 96fb1253..289c7b09 100644 --- a/42sh/includes/builtin.h +++ b/42sh/includes/builtin.h @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/14 22:59:57 by jhalford #+# #+# */ -/* Updated: 2017/03/22 17:28:02 by ariard ### ########.fr */ +/* Updated: 2017/03/24 15:13:06 by wescande ### ########.fr */ /* */ /* ************************************************************************** */ @@ -49,6 +49,7 @@ int builtin_bg(const char *path, char *const av[], char *const envp[]); int builtin_history(const char *path, char *const av[], char *const envp[]); int builtin_hash(const char *path, char *const av[], char *const envp[]); int builtin_math(const char *path, char *const av[], char *const envp[]); +int builtin_func(const char *path, char *const av[], char *const envp[]); int bt_env_geti(char ***av, t_env_data *data); int error_msg(char *msg); diff --git a/42sh/src/builtin/builtin_func.c b/42sh/src/builtin/builtin_func.c new file mode 100644 index 00000000..efbe3cc8 --- /dev/null +++ b/42sh/src/builtin/builtin_func.c @@ -0,0 +1,46 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* builtin_func.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: wescande +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2017/03/24 15:03:02 by wescande #+# #+# */ +/* Updated: 2017/03/24 15:30:13 by wescande ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "minishell.h" + +#define FUNC_USAGE "func" + +int builtin_func(const char *path, + char *const argv[], char *const envp[]) +{ + t_list *list; + char **name; + t_btree **ast; + + (void)envp; + (void)path; + if (!argv || !argv[0] || argv[1]) + return (SH_ERR("usage: %s", FUNC_USAGE) ? 1 : 1); + list = data_singleton()->lst_func; + DG(); + int toto = 0; + while (list) + { + DG(">>>>>>>%d", toto++); + if (!(ast = list->content)) + return (SH_ERR("unexpected error")); + name = token_to_argv(((t_astnode *)(*ast)->item)->data.cmd.token, 1); + if (name && name[0]) + { + DG(); + ft_putendl(name[0]); + } + ft_tabdel(&name); + list = list->next; + } + return (0); +} diff --git a/42sh/src/builtin/is_builtin.c b/42sh/src/builtin/is_builtin.c index 90a08144..dd931eba 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/21 16:24:41 by jhalford ### ########.fr */ +/* Updated: 2017/03/24 15:12:42 by wescande ### ########.fr */ /* */ /* ************************************************************************** */ @@ -30,6 +30,7 @@ t_stof g_builtin[] = {"hash", &builtin_hash}, {"history", &builtin_history}, {"math", &builtin_math}, + {"func", &builtin_func}, {NULL, NULL}, }; diff --git a/42sh/src/main/data_exit.c b/42sh/src/main/data_exit.c index e0f79a5f..f305fbf1 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:48:41 by wescande ### ########.fr */ /* */ /* ************************************************************************** */ @@ -17,12 +17,14 @@ void data_exit(void) t_data *data; data = data_singleton(); + ft_strdel(&data->binary); ft_sstrfree(data->env); ft_sstrfree(data->local_var); ft_sstrfree(data->argv); lexer_destroy(&data->lexer); parser_destroy(&data->parser); ft_lstdel(&data->jobc.first_job, &job_free); + ft_lstdel(&data->lst_func, &tree_func_free); ft_save_termios(-1); ft_free_hash_table(); free_history_list(data_singleton()->line.list_beg); From 05e4ce4c02886db683a87ff99fc3295f7107b03f Mon Sep 17 00:00:00 2001 From: gwojda Date: Fri, 24 Mar 2017 16:12:03 +0100 Subject: [PATCH 05/10] fix echappement des bslash dans dquote --- 42sh/src/lexer/lexer_dquote.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/42sh/src/lexer/lexer_dquote.c b/42sh/src/lexer/lexer_dquote.c index 1786990d..51e50643 100644 --- a/42sh/src/lexer/lexer_dquote.c +++ b/42sh/src/lexer/lexer_dquote.c @@ -3,10 +3,10 @@ /* ::: :::::::: */ /* lexer_dquote.c :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ +/* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/28 18:36:58 by jhalford #+# #+# */ -/* Updated: 2017/03/22 23:56:49 by jhalford ### ########.fr */ +/* Updated: 2017/03/24 16:08:35 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -27,9 +27,9 @@ int lexer_dquote(t_list **alst, t_lexer *lexer) } else if (lexer->str[lexer->pos] == '\\') { - if (lexer->str[lexer->pos + 1] == 0) - return (lexer_backslash(alst, lexer)); - token_append(token, lexer, 1, 1); + lexer->pos++; + if (lexer->str[lexer->pos] == 0) + return (push(&lexer->stack, BACKSLASH) ? 0 : 0); } else if (lexer->str[lexer->pos] == '`' && (lexer->state = BQUOTE)) return (lexer_lex(alst, lexer)); From 933e91217074df8d318250c681f02496831f6cb7 Mon Sep 17 00:00:00 2001 From: wescande Date: Fri, 24 Mar 2017 16:58:54 +0100 Subject: [PATCH 06/10] mise a la norme --- 42sh/includes/types.h | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/42sh/includes/types.h b/42sh/includes/types.h index fc142314..a2019b73 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/22 19:36:55 by jhalford ### ########.fr */ +/* Updated: 2017/03/24 16:58:22 by wescande ### ########.fr */ /* */ /* ************************************************************************** */ @@ -48,14 +48,13 @@ typedef struct s_data_template t_btexport; typedef enum e_lexstate t_lexstate; typedef struct s_token t_token; typedef struct s_rvwords t_rvwords; - typedef struct s_ld t_ld; /* ** Execution types */ -typedef int t_condition; +typedef int t_condition; typedef struct s_job t_job; typedef struct s_process t_process; typedef int (t_execf)(const char *path, @@ -64,11 +63,9 @@ typedef int (t_execf)(const char *path, typedef enum e_process_type t_process_type; typedef enum e_process_state t_process_state; typedef union u_process_data t_process_data; -typedef struct s_process_map t_process_map; +typedef struct s_process_map t_process_map; typedef struct s_data_cond t_data_while; typedef struct s_data_cond t_data_if; -typedef struct s_data_cond t_data_if; - /* ** Parser types From 57d206d7c751484c017c0b0667e22200f29e27de Mon Sep 17 00:00:00 2001 From: gwojda Date: Fri, 24 Mar 2017 16:59:36 +0100 Subject: [PATCH 07/10] norme --- 42sh/includes/job_control.h | 4 ++-- 42sh/includes/types.h | 8 +++----- 42sh/libft/src/btree/btree_map.c | 4 ++-- 42sh/libft/src/error/error.c | 7 ++++--- 42sh/src/builtin/builtin_func.c | 5 +---- 42sh/src/builtin/builtin_read.c | 4 ++-- 42sh/src/main/data_init.c | 6 +++--- 42sh/src/main/ft_putast.c | 8 ++++---- 8 files changed, 21 insertions(+), 25 deletions(-) diff --git a/42sh/includes/job_control.h b/42sh/includes/job_control.h index 7a947624..ddf9e390 100644 --- a/42sh/includes/job_control.h +++ b/42sh/includes/job_control.h @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/10 16:55:09 by jhalford #+# #+# */ -/* Updated: 2017/03/24 15:07:50 by gwojda ### ########.fr */ +/* Updated: 2017/03/24 16:17:40 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -81,7 +81,7 @@ void process_format(t_list **p, int firstp, int opts); */ void pprint(t_process *p); -int pprint_subshell(t_process *p);; +int pprint_subshell(t_process *p); int pprint_brace(t_process *p); int pprint_while(t_process *p); int pprint_if(t_process *p); diff --git a/42sh/includes/types.h b/42sh/includes/types.h index fc142314..99be9273 100644 --- a/42sh/includes/types.h +++ b/42sh/includes/types.h @@ -3,10 +3,10 @@ /* ::: :::::::: */ /* types.h :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ +/* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/13 17:11:48 by jhalford #+# #+# */ -/* Updated: 2017/03/22 19:36:55 by jhalford ### ########.fr */ +/* Updated: 2017/03/24 16:21:12 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -55,7 +55,7 @@ typedef struct s_ld t_ld; ** Execution types */ -typedef int t_condition; +typedef int t_condition; typedef struct s_job t_job; typedef struct s_process t_process; typedef int (t_execf)(const char *path, @@ -67,8 +67,6 @@ typedef union u_process_data t_process_data; typedef struct s_process_map t_process_map; typedef struct s_data_cond t_data_while; typedef struct s_data_cond t_data_if; -typedef struct s_data_cond t_data_if; - /* ** Parser types diff --git a/42sh/libft/src/btree/btree_map.c b/42sh/libft/src/btree/btree_map.c index 85439a1a..47b92852 100644 --- a/42sh/libft/src/btree/btree_map.c +++ b/42sh/libft/src/btree/btree_map.c @@ -3,10 +3,10 @@ /* ::: :::::::: */ /* btree_map.c :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ +/* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/08 11:50:46 by jhalford #+# #+# */ -/* Updated: 2017/03/21 15:42:18 by jhalford ### ########.fr */ +/* Updated: 2017/03/24 15:49:42 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/libft/src/error/error.c b/42sh/libft/src/error/error.c index 4b743cea..1f8b980d 100644 --- a/42sh/libft/src/error/error.c +++ b/42sh/libft/src/error/error.c @@ -3,10 +3,10 @@ /* ::: :::::::: */ /* error.c :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ +/* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/14 16:47:00 by jhalford #+# #+# */ -/* Updated: 2017/03/24 15:36:34 by jhalford ### ########.fr */ +/* Updated: 2017/03/24 16:22:55 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -39,6 +39,7 @@ int error_set(int n, ...) int ft_perror(char *utility) { - ft_dprintf(2, "{red}%s: %s{eoc}\n", utility ? utility : 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_func.c b/42sh/src/builtin/builtin_func.c index efbe3cc8..f9129d66 100644 --- a/42sh/src/builtin/builtin_func.c +++ b/42sh/src/builtin/builtin_func.c @@ -6,7 +6,7 @@ /* By: wescande +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/24 15:03:02 by wescande #+# #+# */ -/* Updated: 2017/03/24 15:30:13 by wescande ### ########.fr */ +/* Updated: 2017/03/24 16:22:13 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -26,11 +26,8 @@ int builtin_func(const char *path, if (!argv || !argv[0] || argv[1]) return (SH_ERR("usage: %s", FUNC_USAGE) ? 1 : 1); list = data_singleton()->lst_func; - DG(); - int toto = 0; while (list) { - DG(">>>>>>>%d", toto++); if (!(ast = list->content)) return (SH_ERR("unexpected error")); name = token_to_argv(((t_astnode *)(*ast)->item)->data.cmd.token, 1); diff --git a/42sh/src/builtin/builtin_read.c b/42sh/src/builtin/builtin_read.c index abea9035..d003a988 100644 --- a/42sh/src/builtin/builtin_read.c +++ b/42sh/src/builtin/builtin_read.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/01/20 15:01:45 by jhalford #+# #+# */ -/* Updated: 2017/03/24 15:10:57 by jhalford ### ########.fr */ +/* Updated: 2017/03/24 16:23:51 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -39,7 +39,7 @@ int bt_read_init(t_read *data, char **av) if (isatty(STDIN)) data->opts |= BT_READ_INTER; if (bt_read_terminit(data) < 0) - exit (1); + exit(1); if ((cliopts_get(av, g_read_opts, data))) return (ft_perror("read")); return (0); diff --git a/42sh/src/main/data_init.c b/42sh/src/main/data_init.c index 46104d14..2594da36 100644 --- a/42sh/src/main/data_init.c +++ b/42sh/src/main/data_init.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/28 19:26:32 by jhalford #+# #+# */ -/* Updated: 2017/03/24 13:51:24 by wescande ### ########.fr */ +/* Updated: 2017/03/24 16:27:51 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -92,12 +92,12 @@ int data_init(int ac, char **av) term_name = "dumb"; if (tgetent(NULL, term_name) != 1) { - ft_dprintf(2, "{red}TERM name is not a tty\n{eoc}"); + SH_ERR("TERM name is not a tty"); return (-1); } if (path_binary_save(av[0])) { - ft_dprintf(2, "{red}Failed to resolve binary name\n{eoc}"); + SH_ERR("Failed to resolve binary name"); return (-1); } return (0); diff --git a/42sh/src/main/ft_putast.c b/42sh/src/main/ft_putast.c index 0d830c1c..30df296b 100644 --- a/42sh/src/main/ft_putast.c +++ b/42sh/src/main/ft_putast.c @@ -1,12 +1,12 @@ /* ************************************************************************** */ /* */ /* ::: :::::::: */ -/* tree_type.c :+: :+: :+: */ +/* ft_putast.c :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ +/* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/14 18:18:04 by jhalford #+# #+# */ -/* Updated: 2017/03/14 22:11:26 by ariard ### ########.fr */ +/* Updated: 2017/03/24 16:28:14 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -16,7 +16,7 @@ char *ft_putast(void *nodein) { t_astnode *node; node = nodein; - + if (node->type == TK_BANG) return ("TK_BANG"); if (node->type == TK_DSEMI) From c2f9ecbcab2114b7c8127f787041c137cb98736f Mon Sep 17 00:00:00 2001 From: wescande Date: Fri, 24 Mar 2017 17:01:14 +0100 Subject: [PATCH 08/10] norme on BT_func --- 42sh/src/builtin/builtin_func.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/42sh/src/builtin/builtin_func.c b/42sh/src/builtin/builtin_func.c index efbe3cc8..419e60b1 100644 --- a/42sh/src/builtin/builtin_func.c +++ b/42sh/src/builtin/builtin_func.c @@ -6,7 +6,7 @@ /* By: wescande +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/24 15:03:02 by wescande #+# #+# */ -/* Updated: 2017/03/24 15:30:13 by wescande ### ########.fr */ +/* Updated: 2017/03/24 17:00:56 by wescande ### ########.fr */ /* */ /* ************************************************************************** */ @@ -26,11 +26,8 @@ int builtin_func(const char *path, if (!argv || !argv[0] || argv[1]) return (SH_ERR("usage: %s", FUNC_USAGE) ? 1 : 1); list = data_singleton()->lst_func; - DG(); - int toto = 0; while (list) { - DG(">>>>>>>%d", toto++); if (!(ast = list->content)) return (SH_ERR("unexpected error")); name = token_to_argv(((t_astnode *)(*ast)->item)->data.cmd.token, 1); From 9c60efc70ceaa28cb38f8c7dfa0680d7399e57a7 Mon Sep 17 00:00:00 2001 From: wescande Date: Fri, 24 Mar 2017 17:03:00 +0100 Subject: [PATCH 09/10] norm on lexer_bquote --- 42sh/src/lexer/lexer_bquote.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/42sh/src/lexer/lexer_bquote.c b/42sh/src/lexer/lexer_bquote.c index c2749334..ff9fff8c 100644 --- a/42sh/src/lexer/lexer_bquote.c +++ b/42sh/src/lexer/lexer_bquote.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/09 22:03:48 by jhalford #+# #+# */ -/* Updated: 2017/03/23 15:17:27 by jhalford ### ########.fr */ +/* Updated: 2017/03/24 17:02:40 by wescande ### ########.fr */ /* */ /* ************************************************************************** */ @@ -25,10 +25,8 @@ int lexer_bquote(t_list **alst, t_lexer *lexer) if (get_lexer_stack(*lexer) != BQUOTE) push(&lexer->stack, lexer->state); else - { lexer->state = pop(&lexer->stack) && get_lexer_stack(*lexer) == DQUOTE ? DQUOTE : DEFAULT; - } } else if (lexer->str[lexer->pos] == '\\' && (back = 1)) { From bf093784d39e1e2fd53c5e8b2e8711e4b67caac2 Mon Sep 17 00:00:00 2001 From: wescande Date: Fri, 24 Mar 2017 17:05:49 +0100 Subject: [PATCH 10/10] norme on shell_init --- 42sh/src/main/shell_init.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/42sh/src/main/shell_init.c b/42sh/src/main/shell_init.c index 16844a6f..c1882171 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/24 15:12:31 by jhalford ### ########.fr */ +/* Updated: 2017/03/24 17:05:29 by wescande ### ########.fr */ /* */ /* ************************************************************************** */ @@ -29,10 +29,9 @@ int get_c_arg(char ***av, t_data *data) return (0); } -static int get_input_fd(t_data *data) +static int get_input_fd(t_data *data, char *file) { static int fds[2] = {-1, STDIN}; - char *file; struct stat buf; if (data->opts & SH_OPTS_LC && (file = data->c_arg)) @@ -94,7 +93,7 @@ int shell_init(int ac, char **av) } if (!isatty(STDIN) || *data->av_data) data->opts &= ~(SH_INTERACTIVE | SH_OPTS_JOBC); - if ((data->fd = get_input_fd(data)) < 0) + if ((data->fd = get_input_fd(data, NULL)) < 0) return (-1); if (SH_IS_INTERACTIVE(data->opts) && interactive_settings() < 0) return (-1);