replaced occurrences of last exit_status
+ deleted envp comments + WIP Macro exit status + TODO : Invalid free of environ in readline
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
|
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2021/10/03 19:14:46 by lperrey #+# #+# */
|
/* Created: 2021/10/03 19:14:46 by lperrey #+# #+# */
|
||||||
/* Updated: 2021/10/26 14:53:32 by lperrey ### ########.fr */
|
/* Updated: 2021/11/27 09:09:31 by lperrey ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -38,8 +38,8 @@
|
|||||||
|
|
||||||
# include <stdio.h>
|
# include <stdio.h>
|
||||||
|
|
||||||
# include "minishell_structs.h"
|
|
||||||
# include "minishell_macro.h"
|
# include "minishell_macro.h"
|
||||||
|
# include "minishell_structs.h"
|
||||||
# include "minishell_term_colors.h"
|
# include "minishell_term_colors.h"
|
||||||
# include "minishell_user_macro.h"
|
# include "minishell_user_macro.h"
|
||||||
# include "minishell_prototypes.h"
|
# include "minishell_prototypes.h"
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
|
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2021/10/08 02:35:55 by lperrey #+# #+# */
|
/* Created: 2021/10/08 02:35:55 by lperrey #+# #+# */
|
||||||
/* Updated: 2021/10/30 22:32:48 by lperrey ### ########.fr */
|
/* Updated: 2021/11/27 10:43:43 by lperrey ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -18,10 +18,37 @@
|
|||||||
# define PROMPT_CHEVRON "> "
|
# define PROMPT_CHEVRON "> "
|
||||||
# define PROMPT_EURO "\001€\002 \001\b\002"
|
# define PROMPT_EURO "\001€\002 \001\b\002"
|
||||||
|
|
||||||
|
# define EXIT_CMD_NOT_FOUND 127
|
||||||
|
# define EXIT_CMD_NOT_EXE 126
|
||||||
|
# define EXIT_SIGNAL 128
|
||||||
|
|
||||||
|
// 1 and 125 inclusive
|
||||||
|
# define EXIT_REDIRECTION 22
|
||||||
|
# define EXIT_EXPANSION 33
|
||||||
|
|
||||||
enum e_lexer_return
|
enum e_lexer_return
|
||||||
{
|
{
|
||||||
CONTINUE_TOKEN = 1,
|
CONTINUE_TOKEN = 1,
|
||||||
DELIMITE_TOKEN
|
DELIMITE_TOKEN
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum e_token_id
|
||||||
|
{
|
||||||
|
T_LESS = '<',
|
||||||
|
T_GREAT = '>',
|
||||||
|
T_PIPE = '|',
|
||||||
|
T_DLESS,
|
||||||
|
T_DGREAT,
|
||||||
|
T_WORD,
|
||||||
|
T_REDIRECTION_WORD
|
||||||
|
};
|
||||||
|
// T_DLESS == '<<'
|
||||||
|
// T_DGREAT == '>>'
|
||||||
|
|
||||||
|
enum e_quotes_state
|
||||||
|
{
|
||||||
|
IN_QUOTES = '\'',
|
||||||
|
IN_DQUOTES = '\"'
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -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 21:45:26 by lperrey ### ########.fr */
|
/* Updated: 2021/11/27 12:28:20 by lperrey ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -16,10 +16,12 @@
|
|||||||
// variable globale
|
// variable globale
|
||||||
int g_switch_heredoc_sigint;
|
int g_switch_heredoc_sigint;
|
||||||
extern char **environ;
|
extern char **environ;
|
||||||
|
char **g_ori_environ; // WIP free test
|
||||||
|
|
||||||
// Init
|
// Init
|
||||||
int init(t_all *c);
|
int init(t_all *c);
|
||||||
char **retrieve_path(char *envp[]);
|
char *init_prompt(char *prompt_base);
|
||||||
|
char **retrieve_path(void);
|
||||||
int set_terminal_attributes(struct termios *ori_termios,
|
int set_terminal_attributes(struct termios *ori_termios,
|
||||||
struct termios *interactive_termios,
|
struct termios *interactive_termios,
|
||||||
int *termios_changed); // WIP, TEST, TEMP, PLACEHOLDER, NOT IMPORTANT, :)
|
int *termios_changed); // WIP, TEST, TEMP, PLACEHOLDER, NOT IMPORTANT, :)
|
||||||
@@ -49,7 +51,7 @@ int exec_cmd_line(t_all *c);
|
|||||||
int pipeline(t_all *c);
|
int pipeline(t_all *c);
|
||||||
int cmd_find_access(t_cmd *cmd, char *path[]);
|
int cmd_find_access(t_cmd *cmd, char *path[]);
|
||||||
int cmd_exec_in_subshell(t_cmd *cmd, t_all *c);
|
int cmd_exec_in_subshell(t_cmd *cmd, t_all *c);
|
||||||
void wait_subshell(pid_t last_cmd_pid, int *last_exit_status);
|
void wait_subshell(pid_t last_cmd_pid);
|
||||||
int simple_command_builtin(t_cmd *cmd, t_all *c);
|
int simple_command_builtin(t_cmd *cmd, t_all *c);
|
||||||
|
|
||||||
// Builtins
|
// Builtins
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* 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:53:39 by lperrey ### ########.fr */
|
/* Updated: 2021/11/27 11:28:13 by lperrey ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -15,25 +15,6 @@
|
|||||||
|
|
||||||
struct s_all;
|
struct s_all;
|
||||||
|
|
||||||
enum e_token_id
|
|
||||||
{
|
|
||||||
T_LESS = '<',
|
|
||||||
T_GREAT = '>',
|
|
||||||
T_PIPE = '|',
|
|
||||||
T_DLESS,
|
|
||||||
T_DGREAT,
|
|
||||||
T_WORD,
|
|
||||||
T_REDIRECTION_WORD
|
|
||||||
};
|
|
||||||
// T_DLESS == '<<'
|
|
||||||
// T_DGREAT == '>>'
|
|
||||||
|
|
||||||
enum e_quotes_state
|
|
||||||
{
|
|
||||||
IN_QUOTES = '\'',
|
|
||||||
IN_DQUOTES = '\"'
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef struct s_token
|
typedef struct s_token
|
||||||
{
|
{
|
||||||
char *content;
|
char *content;
|
||||||
@@ -57,12 +38,10 @@ typedef struct s_cmd
|
|||||||
typedef struct s_all
|
typedef struct s_all
|
||||||
{
|
{
|
||||||
t_cmd **cmd_arr;
|
t_cmd **cmd_arr;
|
||||||
// char **envp;
|
|
||||||
char **path;
|
char **path;
|
||||||
char *prompt_base;
|
char *prompt_base;
|
||||||
char *prompt;
|
char *prompt;
|
||||||
t_token *token_list;
|
t_token *token_list;
|
||||||
int last_exit_status;
|
|
||||||
// struct termios ori_termios;
|
// struct termios ori_termios;
|
||||||
// struct termios interactive_termios;
|
// struct termios interactive_termios;
|
||||||
// int termios_changed;
|
// int termios_changed;
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
|
|
||||||
#include "minishell.h"
|
#include "minishell.h"
|
||||||
|
|
||||||
// a integrer dans header
|
|
||||||
char *init_prompt(char *prompt_base);
|
|
||||||
|
|
||||||
int builtin_cd(int argc, char *argv[], t_all *c)
|
int builtin_cd(int argc, char *argv[], t_all *c)
|
||||||
{
|
{
|
||||||
(void)argc;
|
(void)argc;
|
||||||
|
|||||||
@@ -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/26 21:51:48 by lperrey ### ########.fr */
|
/* Updated: 2021/11/27 11:18:55 by lperrey ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -16,7 +16,6 @@ int builtin_env(int argc, char *argv[], t_all *c) // WIP
|
|||||||
{
|
{
|
||||||
(void)argc;
|
(void)argc;
|
||||||
(void)argv;
|
(void)argv;
|
||||||
//ft_putendl_arr_fd(c->envp, 1);
|
|
||||||
ft_putendl_arr_fd(environ, 1);
|
ft_putendl_arr_fd(environ, 1);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
|
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2021/10/10 05:01:22 by lperrey #+# #+# */
|
/* Created: 2021/10/10 05:01:22 by lperrey #+# #+# */
|
||||||
/* Updated: 2021/10/22 14:49:01 by lperrey ### ########.fr */
|
/* Updated: 2021/11/27 10:47:32 by lperrey ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -17,7 +17,7 @@ int builtin_exit(int argc, char *argv[], t_all *c) // WIP
|
|||||||
unsigned char status;
|
unsigned char status;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
status = c->last_exit_status;
|
status = get_last_exit_status();
|
||||||
if (argc > 2)
|
if (argc > 2)
|
||||||
return (ft_reti_print(1, "exit: too many arguments\n", 2));
|
return (ft_reti_print(1, "exit: too many arguments\n", 2));
|
||||||
if (argc == 2)
|
if (argc == 2)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
#include "minishell.h"
|
#include "minishell.h"
|
||||||
|
|
||||||
int getenv_position(char **envp, char *name)
|
int getenv_position(char **envp, char *name) // TODO : virer arg envp et utiliser "extern **environ" à la place
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@ int builtin_export(int argc, char *argv[], t_all *c)
|
|||||||
environ = ft_resize_2d_arr(environ, 1);
|
environ = ft_resize_2d_arr(environ, 1);
|
||||||
environ[env_position] = ft_strdup(argv[1]);
|
environ[env_position] = ft_strdup(argv[1]);
|
||||||
if (!ft_strncmp(var[0], "PATH", 4 + 1))
|
if (!ft_strncmp(var[0], "PATH", 4 + 1))
|
||||||
c->path = retrieve_path(environ);
|
c->path = retrieve_path();
|
||||||
// free var
|
// free var
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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/18 23:08:16 by hulamy ### ########.fr */
|
/* Updated: 2021/11/27 10:48:13 by lperrey ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -25,7 +25,7 @@ int pipeline(t_all *c)
|
|||||||
if (ft_2d_arrlen(c->cmd_arr) == 1 && c->cmd_arr[0]->builtin_func)
|
if (ft_2d_arrlen(c->cmd_arr) == 1 && c->cmd_arr[0]->builtin_func)
|
||||||
simple_command_builtin(c->cmd_arr[0], c);
|
simple_command_builtin(c->cmd_arr[0], c);
|
||||||
else
|
else
|
||||||
wait_subshell(pipeline_exec(c->cmd_arr, c), &c->last_exit_status);
|
wait_subshell(pipeline_exec(c->cmd_arr, c));
|
||||||
free_pipeline(&c->cmd_arr);
|
free_pipeline(&c->cmd_arr);
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
@@ -90,6 +90,6 @@ static pid_t pipeline_exec(t_cmd *pipeline[], t_all *c)
|
|||||||
close_pipeline_fd(c->cmd_arr);
|
close_pipeline_fd(c->cmd_arr);
|
||||||
i -= 1;
|
i -= 1;
|
||||||
if (pipeline[i]->error)
|
if (pipeline[i]->error)
|
||||||
c->last_exit_status = pipeline[i]->error;
|
set_last_exit_status(pipeline[i]->error);
|
||||||
return (pipeline[i]->pid);
|
return (pipeline[i]->pid);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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/18 14:08:56 by lperrey ### ########.fr */
|
/* Updated: 2021/11/27 11:07:19 by lperrey ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -37,7 +37,7 @@ int simple_command_builtin(t_cmd *cmd, t_all *c)
|
|||||||
if (dup2(cmd->fd_out, STDOUT_FILENO) == -1)
|
if (dup2(cmd->fd_out, STDOUT_FILENO) == -1)
|
||||||
return (ft_reti_perror(EXIT_FAILURE, "dup2()"));
|
return (ft_reti_perror(EXIT_FAILURE, "dup2()"));
|
||||||
}
|
}
|
||||||
c->last_exit_status = cmd->builtin_func(ft_2d_arrlen(cmd->argv), cmd->argv, c);
|
set_last_exit_status(cmd->builtin_func(ft_2d_arrlen(cmd->argv), cmd->argv, c));
|
||||||
if (!restore_stdio(stdin_dup, stdout_dup))
|
if (!restore_stdio(stdin_dup, stdout_dup))
|
||||||
return (EXIT_FAILURE);
|
return (EXIT_FAILURE);
|
||||||
return (EXIT_SUCCESS);
|
return (EXIT_SUCCESS);
|
||||||
|
|||||||
@@ -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/26 21:51:15 by lperrey ### ########.fr */
|
/* Updated: 2021/11/27 11:11:12 by lperrey ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -30,7 +30,6 @@ int cmd_exec_in_subshell(t_cmd *cmd, t_all *c)
|
|||||||
close_pipeline_fd(c->cmd_arr);
|
close_pipeline_fd(c->cmd_arr);
|
||||||
if (cmd->builtin_func)
|
if (cmd->builtin_func)
|
||||||
free_exit(c, cmd->builtin_func(ft_2d_arrlen(cmd->argv), cmd->argv, c));
|
free_exit(c, cmd->builtin_func(ft_2d_arrlen(cmd->argv), cmd->argv, c));
|
||||||
//else if (execve(cmd->path, cmd->argv, c->envp) == -1)
|
|
||||||
else if (execve(cmd->path, cmd->argv, environ) == -1)
|
else if (execve(cmd->path, cmd->argv, environ) == -1)
|
||||||
return (ft_reti_perror_io(EXIT_FAILURE, "execve() ", cmd->argv[0]));
|
return (ft_reti_perror_io(EXIT_FAILURE, "execve() ", cmd->argv[0]));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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/18 23:09:46 by hulamy ### ########.fr */
|
/* Updated: 2021/11/27 10:43:46 by lperrey ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
static int handle_wait_error(void);
|
static int handle_wait_error(void);
|
||||||
|
|
||||||
void wait_subshell(pid_t last_cmd_pid, int *last_exit_status)
|
void wait_subshell(pid_t last_cmd_pid)
|
||||||
{
|
{
|
||||||
int wstatus;
|
int wstatus;
|
||||||
int ret;
|
int ret;
|
||||||
@@ -25,11 +25,11 @@ void wait_subshell(pid_t last_cmd_pid, int *last_exit_status)
|
|||||||
if (waitpid(last_cmd_pid, &wstatus, 0) == -1)
|
if (waitpid(last_cmd_pid, &wstatus, 0) == -1)
|
||||||
perror("waitpid()");
|
perror("waitpid()");
|
||||||
if (WIFEXITED(wstatus))
|
if (WIFEXITED(wstatus))
|
||||||
*last_exit_status = WEXITSTATUS(wstatus);
|
set_last_exit_status(WEXITSTATUS(wstatus));
|
||||||
if (WIFSIGNALED(wstatus))
|
if (WIFSIGNALED(wstatus))
|
||||||
{
|
{
|
||||||
write(STDIN_FILENO, "\n", 1);
|
write(STDIN_FILENO, "\n", 1);
|
||||||
*last_exit_status = 128 + WTERMSIG(wstatus);
|
set_last_exit_status(EXIT_SIGNAL + WTERMSIG(wstatus));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
|
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2021/10/08 09:25:35 by lperrey #+# #+# */
|
/* Created: 2021/10/08 09:25:35 by lperrey #+# #+# */
|
||||||
/* Updated: 2021/11/14 08:27:40 by lperrey ### ########.fr */
|
/* Updated: 2021/11/27 12:58:20 by lperrey ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -84,7 +84,7 @@ size_t ft_2d_arrlen(void *ptr) // Replace ft_arrlen()
|
|||||||
len++;
|
len++;
|
||||||
return (len);
|
return (len);
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
char **ft_dup_2d_char_arr(char **ptr) // Superflu si ft_dup_2d_arr() fonctionne
|
char **ft_dup_2d_char_arr(char **ptr) // Superflu si ft_dup_2d_arr() fonctionne
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
@@ -105,7 +105,7 @@ char **ft_dup_2d_char_arr(char **ptr) // Superflu si ft_dup_2d_arr() fonctionne
|
|||||||
}
|
}
|
||||||
new_arr[i] = NULL;
|
new_arr[i] = NULL;
|
||||||
return (new_arr);
|
return (new_arr);
|
||||||
}
|
} */
|
||||||
|
|
||||||
// Test generic. Pas certain que ça fonctionne bien avec le pointeur sur fonction
|
// Test generic. Pas certain que ça fonctionne bien avec le pointeur sur fonction
|
||||||
void *ft_dup_2d_arr(void *ptr, void *(*dup_func)(void *))
|
void *ft_dup_2d_arr(void *ptr, void *(*dup_func)(void *))
|
||||||
@@ -114,7 +114,7 @@ void *ft_dup_2d_arr(void *ptr, void *(*dup_func)(void *))
|
|||||||
char **arr;
|
char **arr;
|
||||||
char **new_arr;
|
char **new_arr;
|
||||||
|
|
||||||
new_arr = malloc((ft_2d_arrlen(ptr) + 1) * sizeof (void *));
|
new_arr = ft_calloc(ft_2d_arrlen(ptr) + 1, sizeof (void *));
|
||||||
if (!new_arr)
|
if (!new_arr)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
arr = (char **)ptr;
|
arr = (char **)ptr;
|
||||||
@@ -126,7 +126,6 @@ void *ft_dup_2d_arr(void *ptr, void *(*dup_func)(void *))
|
|||||||
return (ft_retp_free(NULL, new_arr, ft_free_2d_arr));
|
return (ft_retp_free(NULL, new_arr, ft_free_2d_arr));
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
new_arr[i] = NULL;
|
|
||||||
return (new_arr);
|
return (new_arr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,13 +6,12 @@
|
|||||||
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
|
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2021/10/04 05:59:26 by lperrey #+# #+# */
|
/* Created: 2021/10/04 05:59:26 by lperrey #+# #+# */
|
||||||
/* Updated: 2021/11/26 20:33:54 by lperrey ### ########.fr */
|
/* Updated: 2021/11/27 11:19:15 by lperrey ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "minishell.h"
|
#include "minishell.h"
|
||||||
|
|
||||||
//int main(int argc, char *argv[], char *envp[])
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
t_all c;
|
t_all c;
|
||||||
|
|||||||
@@ -6,19 +6,12 @@
|
|||||||
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
|
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2021/10/24 10:52:40 by lperrey #+# #+# */
|
/* Created: 2021/10/24 10:52:40 by lperrey #+# #+# */
|
||||||
/* Updated: 2021/11/18 22:35:07 by hulamy ### ########.fr */
|
/* Updated: 2021/11/27 11:09:48 by lperrey ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "minishell.h"
|
#include "minishell.h"
|
||||||
|
|
||||||
// HUGO WIP
|
|
||||||
void handle_path(t_cmd **cmd_arr, char **envp);
|
|
||||||
void find_path(char **argv, char **envp);
|
|
||||||
int handle_builtin(t_cmd *cmd);
|
|
||||||
int fill_builtin(t_cmd *cmd, int (*builtin)(int, char **, t_all *));
|
|
||||||
// HUGO WIP
|
|
||||||
|
|
||||||
void save_redirections_words(t_token *t)
|
void save_redirections_words(t_token *t)
|
||||||
{
|
{
|
||||||
while (t)
|
while (t)
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
|
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2021/10/04 05:59:26 by lperrey #+# #+# */
|
/* Created: 2021/10/04 05:59:26 by lperrey #+# #+# */
|
||||||
/* Updated: 2021/11/17 15:29:35 by hulamy ### ########.fr */
|
/* Updated: 2021/11/27 10:47:05 by lperrey ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ void shell_loop(t_all *c)
|
|||||||
else if (!line_input)
|
else if (!line_input)
|
||||||
{
|
{
|
||||||
write(1, "exit\n", 5);
|
write(1, "exit\n", 5);
|
||||||
free_exit(c, c->last_exit_status);
|
free_exit(c, get_last_exit_status());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user