diff --git a/headers/minishell_prototypes.h b/headers/minishell_prototypes.h index 15600bc..7841ea9 100644 --- a/headers/minishell_prototypes.h +++ b/headers/minishell_prototypes.h @@ -6,7 +6,7 @@ /* By: lperrey +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2021/10/08 02:59:58 by lperrey #+# #+# */ -/* Updated: 2021/11/26 19:04:25 by lperrey ### ########.fr */ +/* Updated: 2021/11/26 21:45:26 by lperrey ### ########.fr */ /* */ /* ************************************************************************** */ @@ -14,7 +14,8 @@ # define MINISHELL_PROTOTYPES_H // variable globale -int switch_heredoc_sigint; +int g_switch_heredoc_sigint; +extern char **environ; // Init int init(t_all *c); diff --git a/headers/minishell_structs.h b/headers/minishell_structs.h index 739b684..e80ee31 100644 --- a/headers/minishell_structs.h +++ b/headers/minishell_structs.h @@ -6,14 +6,14 @@ /* By: lperrey +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2021/10/08 02:35:52 by lperrey #+# #+# */ -/* Updated: 2021/11/26 21:28:55 by lperrey ### ########.fr */ +/* Updated: 2021/11/26 21:53:39 by lperrey ### ########.fr */ /* */ /* ************************************************************************** */ #ifndef MINISHELL_STRUCTS_H # define MINISHELL_STRUCTS_H -struct s_all *g_all; +struct s_all; enum e_token_id { diff --git a/srcs/builtins/env.c b/srcs/builtins/env.c index 1b5b0b5..c0e4ef9 100644 --- a/srcs/builtins/env.c +++ b/srcs/builtins/env.c @@ -6,7 +6,7 @@ /* By: lperrey +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2021/10/10 05:01:26 by lperrey #+# #+# */ -/* Updated: 2021/11/25 19:01:13 by hulamy ### ########.fr */ +/* Updated: 2021/11/26 21:51:48 by lperrey ### ########.fr */ /* */ /* ************************************************************************** */ @@ -14,8 +14,6 @@ int builtin_env(int argc, char *argv[], t_all *c) // WIP { - extern char **environ; - (void)argc; (void)argv; //ft_putendl_arr_fd(c->envp, 1); diff --git a/srcs/builtins/export.c b/srcs/builtins/export.c index 3385e49..e85543d 100644 --- a/srcs/builtins/export.c +++ b/srcs/builtins/export.c @@ -13,7 +13,6 @@ int getenv_position(char **envp, char *name) int builtin_export(int argc, char *argv[], t_all *c) { - extern char **environ; char **var; int env_position; diff --git a/srcs/builtins/unset.c b/srcs/builtins/unset.c index 4b81500..755c76f 100644 --- a/srcs/builtins/unset.c +++ b/srcs/builtins/unset.c @@ -3,7 +3,6 @@ int builtin_unset(int argc, char *argv[], t_all *c) { - extern char **environ; int env_position; int i; diff --git a/srcs/exec/subshell_exec.c b/srcs/exec/subshell_exec.c index 721868e..09fb010 100644 --- a/srcs/exec/subshell_exec.c +++ b/srcs/exec/subshell_exec.c @@ -6,7 +6,7 @@ /* By: lperrey +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2021/11/16 01:57:38 by lperrey #+# #+# */ -/* Updated: 2021/11/25 18:59:02 by hulamy ### ########.fr */ +/* Updated: 2021/11/26 21:51:15 by lperrey ### ########.fr */ /* */ /* ************************************************************************** */ @@ -14,8 +14,6 @@ int cmd_exec_in_subshell(t_cmd *cmd, t_all *c) { - extern char **environ; - cmd->pid = fork(); if (cmd->pid == -1) perror("fork()"); diff --git a/srcs/free.c b/srcs/free.c index 8f223ff..fdda745 100644 --- a/srcs/free.c +++ b/srcs/free.c @@ -6,7 +6,7 @@ /* By: lperrey +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2021/10/10 23:53:17 by lperrey #+# #+# */ -/* Updated: 2021/11/25 16:36:39 by hulamy ### ########.fr */ +/* Updated: 2021/11/26 21:51:44 by lperrey ### ########.fr */ /* */ /* ************************************************************************** */ @@ -14,8 +14,6 @@ int free_exit(t_all *c, int exit_status) { - extern char **environ; - free(c->prompt_base); free(c->prompt); ft_lstclear((t_list **)&c->token_list, free); diff --git a/srcs/init.c b/srcs/init.c index ba18d9d..027a127 100644 --- a/srcs/init.c +++ b/srcs/init.c @@ -6,7 +6,7 @@ /* By: lperrey +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2021/10/08 09:22:12 by lperrey #+# #+# */ -/* Updated: 2021/11/26 19:02:24 by lperrey ### ########.fr */ +/* Updated: 2021/11/26 21:51:40 by lperrey ### ########.fr */ /* */ /* ************************************************************************** */ @@ -20,9 +20,6 @@ char *init_prompt(char *prompt_base); //int init(t_all *c, char *envp[]) int init(t_all *c) { - extern char **environ; - - g_all = c; ft_bzero(c, sizeof (*c)); environ = ft_dup_2d_arr(environ, (t_dup_f)ft_strdup); if (!environ) diff --git a/srcs/parsing/expansions/expand_token.c b/srcs/parsing/expansions/expand_token.c index d0c0a98..90ab62f 100644 --- a/srcs/parsing/expansions/expand_token.c +++ b/srcs/parsing/expansions/expand_token.c @@ -6,7 +6,7 @@ /* By: lperrey +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2021/11/07 02:01:33 by lperrey #+# #+# */ -/* Updated: 2021/11/26 21:02:20 by lperrey ### ########.fr */ +/* Updated: 2021/11/26 21:54:42 by lperrey ### ########.fr */ /* */ /* ************************************************************************** */ @@ -85,7 +85,7 @@ static t_list *ret_parameter_expansion(char *content, int *i) if (content[*i] == '?') { (*i)++; - expand->content = ft_itoa(g_all->last_exit_status); + expand->content = ft_itoa(get_last_exit_status()); return (ft_retp_free(expand, tmp, free)); } else if (content[*i] != '_' && !ft_isalpha(content[*i])) diff --git a/srcs/parsing/redirections/here_doc.c b/srcs/parsing/redirections/here_doc.c index f0d292a..f403171 100644 --- a/srcs/parsing/redirections/here_doc.c +++ b/srcs/parsing/redirections/here_doc.c @@ -6,7 +6,7 @@ /* By: lperrey +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2021/11/11 18:46:43 by lperrey #+# #+# */ -/* Updated: 2021/11/26 20:00:25 by lperrey ### ########.fr */ +/* Updated: 2021/11/26 21:45:17 by lperrey ### ########.fr */ /* */ /* ************************************************************************** */ @@ -83,7 +83,7 @@ static int here_doc_write(char *delimiter, int doc_fd) ft_bzero(&signal_action, sizeof(signal_action)); signal_action.sa_handler = sigint_handler_heredoc; sigaction(SIGINT, &signal_action, NULL); - switch_heredoc_sigint = 0; + g_switch_heredoc_sigint = 0; rl_event_hook = void_func_return_readline; //rl_signal_event_hook = void_func_return_readline; line_count = 0; @@ -92,7 +92,7 @@ static int here_doc_write(char *delimiter, int doc_fd) line_count++; line = NULL; line = readline("> "); - if (switch_heredoc_sigint == 1) + if (g_switch_heredoc_sigint == 1) return (set_last_exit_status(128 + SIGINT)); // TODO Macro for error if (!line) { // TODO : error print wrapper diff --git a/srcs/signals.c b/srcs/signals.c index e0a2371..61445b6 100644 --- a/srcs/signals.c +++ b/srcs/signals.c @@ -6,7 +6,7 @@ /* By: lperrey +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2021/10/23 18:56:53 by lperrey #+# #+# */ -/* Updated: 2021/11/25 10:02:53 by hulamy ### ########.fr */ +/* Updated: 2021/11/26 21:45:22 by lperrey ### ########.fr */ /* */ /* ************************************************************************** */ @@ -24,7 +24,7 @@ void sigint_handler_interactive(int signum) void sigint_handler_heredoc(int signum) { (void)signum; - switch_heredoc_sigint = 1; + g_switch_heredoc_sigint = 1; rl_done = 1; // write (1, rl_line_buffer, ft_strlen(rl_line_buffer) + 1); // rl_line_buffer = "\004";