"extern char **environ" in header file
+ global var g_all deleted, renamed switch_heredoc_sigint
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
|
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2021/10/08 02:59:58 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
|
# define MINISHELL_PROTOTYPES_H
|
||||||
|
|
||||||
// variable globale
|
// variable globale
|
||||||
int switch_heredoc_sigint;
|
int g_switch_heredoc_sigint;
|
||||||
|
extern char **environ;
|
||||||
|
|
||||||
// Init
|
// Init
|
||||||
int init(t_all *c);
|
int init(t_all *c);
|
||||||
|
|||||||
@@ -6,14 +6,14 @@
|
|||||||
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
|
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2021/10/08 02:35:52 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
|
#ifndef MINISHELL_STRUCTS_H
|
||||||
# define MINISHELL_STRUCTS_H
|
# define MINISHELL_STRUCTS_H
|
||||||
|
|
||||||
struct s_all *g_all;
|
struct s_all;
|
||||||
|
|
||||||
enum e_token_id
|
enum e_token_id
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
|
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2021/10/10 05:01:26 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
|
int builtin_env(int argc, char *argv[], t_all *c) // WIP
|
||||||
{
|
{
|
||||||
extern char **environ;
|
|
||||||
|
|
||||||
(void)argc;
|
(void)argc;
|
||||||
(void)argv;
|
(void)argv;
|
||||||
//ft_putendl_arr_fd(c->envp, 1);
|
//ft_putendl_arr_fd(c->envp, 1);
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ int getenv_position(char **envp, char *name)
|
|||||||
|
|
||||||
int builtin_export(int argc, char *argv[], t_all *c)
|
int builtin_export(int argc, char *argv[], t_all *c)
|
||||||
{
|
{
|
||||||
extern char **environ;
|
|
||||||
char **var;
|
char **var;
|
||||||
int env_position;
|
int env_position;
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
int builtin_unset(int argc, char *argv[], t_all *c)
|
int builtin_unset(int argc, char *argv[], t_all *c)
|
||||||
{
|
{
|
||||||
extern char **environ;
|
|
||||||
int env_position;
|
int env_position;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
|
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2021/11/16 01:57:38 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)
|
int cmd_exec_in_subshell(t_cmd *cmd, t_all *c)
|
||||||
{
|
{
|
||||||
extern char **environ;
|
|
||||||
|
|
||||||
cmd->pid = fork();
|
cmd->pid = fork();
|
||||||
if (cmd->pid == -1)
|
if (cmd->pid == -1)
|
||||||
perror("fork()");
|
perror("fork()");
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
|
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2021/10/10 23:53:17 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)
|
int free_exit(t_all *c, int exit_status)
|
||||||
{
|
{
|
||||||
extern char **environ;
|
|
||||||
|
|
||||||
free(c->prompt_base);
|
free(c->prompt_base);
|
||||||
free(c->prompt);
|
free(c->prompt);
|
||||||
ft_lstclear((t_list **)&c->token_list, free);
|
ft_lstclear((t_list **)&c->token_list, free);
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
|
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2021/10/08 09:22:12 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, char *envp[])
|
||||||
int init(t_all *c)
|
int init(t_all *c)
|
||||||
{
|
{
|
||||||
extern char **environ;
|
|
||||||
|
|
||||||
g_all = c;
|
|
||||||
ft_bzero(c, sizeof (*c));
|
ft_bzero(c, sizeof (*c));
|
||||||
environ = ft_dup_2d_arr(environ, (t_dup_f)ft_strdup);
|
environ = ft_dup_2d_arr(environ, (t_dup_f)ft_strdup);
|
||||||
if (!environ)
|
if (!environ)
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
|
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2021/11/07 02:01:33 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] == '?')
|
if (content[*i] == '?')
|
||||||
{
|
{
|
||||||
(*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));
|
return (ft_retp_free(expand, tmp, free));
|
||||||
}
|
}
|
||||||
else if (content[*i] != '_' && !ft_isalpha(content[*i]))
|
else if (content[*i] != '_' && !ft_isalpha(content[*i]))
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
|
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2021/11/11 18:46:43 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));
|
ft_bzero(&signal_action, sizeof(signal_action));
|
||||||
signal_action.sa_handler = sigint_handler_heredoc;
|
signal_action.sa_handler = sigint_handler_heredoc;
|
||||||
sigaction(SIGINT, &signal_action, NULL);
|
sigaction(SIGINT, &signal_action, NULL);
|
||||||
switch_heredoc_sigint = 0;
|
g_switch_heredoc_sigint = 0;
|
||||||
rl_event_hook = void_func_return_readline;
|
rl_event_hook = void_func_return_readline;
|
||||||
//rl_signal_event_hook = void_func_return_readline;
|
//rl_signal_event_hook = void_func_return_readline;
|
||||||
line_count = 0;
|
line_count = 0;
|
||||||
@@ -92,7 +92,7 @@ static int here_doc_write(char *delimiter, int doc_fd)
|
|||||||
line_count++;
|
line_count++;
|
||||||
line = NULL;
|
line = NULL;
|
||||||
line = readline("> ");
|
line = readline("> ");
|
||||||
if (switch_heredoc_sigint == 1)
|
if (g_switch_heredoc_sigint == 1)
|
||||||
return (set_last_exit_status(128 + SIGINT)); // TODO Macro for error
|
return (set_last_exit_status(128 + SIGINT)); // TODO Macro for error
|
||||||
if (!line)
|
if (!line)
|
||||||
{ // TODO : error print wrapper
|
{ // TODO : error print wrapper
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
|
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2021/10/23 18:56:53 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 sigint_handler_heredoc(int signum)
|
||||||
{
|
{
|
||||||
(void)signum;
|
(void)signum;
|
||||||
switch_heredoc_sigint = 1;
|
g_switch_heredoc_sigint = 1;
|
||||||
rl_done = 1;
|
rl_done = 1;
|
||||||
// write (1, rl_line_buffer, ft_strlen(rl_line_buffer) + 1);
|
// write (1, rl_line_buffer, ft_strlen(rl_line_buffer) + 1);
|
||||||
// rl_line_buffer = "\004";
|
// rl_line_buffer = "\004";
|
||||||
|
|||||||
Reference in New Issue
Block a user