WIP exec_cmd_line()

+ fix error handle in redirections()
+ rename ft_free_cmd_arr() to free_pipeline()
+ "char **path" added to "struct t_all"
+ misc
This commit is contained in:
LuckyLaszlo
2021-11-16 08:49:57 +01:00
parent bb77de0588
commit 140549db00
11 changed files with 239 additions and 51 deletions

View File

@@ -6,7 +6,7 @@
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/10/08 09:22:12 by lperrey #+# #+# */
/* Updated: 2021/11/13 05:31:47 by lperrey ### ########.fr */
/* Updated: 2021/11/16 03:45:10 by lperrey ### ########.fr */
/* */
/* ************************************************************************** */
@@ -19,10 +19,11 @@ int init(t_all *c, char *envp[])
{
g_all = c;
ft_bzero(c, sizeof (*c));
c->envp = ft_dup_2d_arr(envp, (t_dup_func)ft_strdup); // TEST WIP
c->envp = ft_dup_2d_arr(envp, (t_dup_f)ft_strdup); // TEST WIP
if (!c->envp)
return (ft_reti_perror(0, "ft_dup_2d_char_arr(envp) error"));
//print_matrix(c->envp, "\n --- \n"); // TEST WIP
c->path = retrieve_path(c->envp); // No return check. Its intended. PATH is optional
c->prompt_base = init_prompt_base();
if (!c->prompt_base)
return (ft_reti_perror(0, "init_prompt_base() error"));
@@ -39,7 +40,24 @@ int init(t_all *c, char *envp[])
return (1);
}
static char *init_prompt_base(void)
// TODO : Un appel à builtin_export() modifiant $PATH doit aussi entrainer un appel à "c->path = retrieve_path()"
char **retrieve_path(char *envp[])
{
char *path;
char **path_split;
(void)envp;
//path = search_env_var(envp, "PATH"); // A reprendre du projet pipex si besoin de remplacer getenv()
path = getenv("PATH");
if (!path)
return (ft_retp_print(NULL, "minishell: Warning, $PATH not set\n", 2));
path_split = ft_split(path, ':');
if (!path_split)
return (ft_retp_perror(NULL, "retrieve_path()"));
return (path_split);
}
static char *init_prompt_base(void) // WIP, error return TODO
{
char *prompt_base;
char *tmp;
@@ -59,7 +77,7 @@ static char *init_prompt_base(void)
return (prompt_base);
}
static char *init_prompt(char *prompt_base)
static char *init_prompt(char *prompt_base) // WIP, error return TODO
{
char *prompt;