cd ok et appel a path dans export
This commit is contained in:
@@ -1,10 +1,15 @@
|
||||
|
||||
#include "minishell.h"
|
||||
|
||||
// a integrer dans header
|
||||
char *init_prompt(char *prompt_base);
|
||||
|
||||
int builtin_cd(int argc, char *argv[], t_all *c)
|
||||
{
|
||||
(void)argc;
|
||||
(void)c;
|
||||
chdir(argv[1]);
|
||||
c->prompt = init_prompt(c->prompt_base);
|
||||
if (!c->prompt)
|
||||
return (ft_reti_perror(0, "init_prompt() error"));
|
||||
return (0);
|
||||
}
|
||||
|
||||
@@ -26,6 +26,8 @@ int builtin_export(int argc, char *argv[], t_all *c)
|
||||
if (environ[env_position] == '\0')
|
||||
environ = ft_resize_2d_arr(environ, 1);
|
||||
environ[env_position] = ft_strdup(argv[1]);
|
||||
if (!ft_strncmp(var[0], "PATH", 4 + 1))
|
||||
c->path = retrieve_path(environ);
|
||||
// free var
|
||||
return (0);
|
||||
}
|
||||
|
||||
12
srcs/init.c
12
srcs/init.c
@@ -6,14 +6,16 @@
|
||||
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2021/10/08 09:22:12 by lperrey #+# #+# */
|
||||
/* Updated: 2021/11/25 19:47:00 by hulamy ### ########.fr */
|
||||
/* Updated: 2021/11/25 23:59:33 by hulamy ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "minishell.h"
|
||||
|
||||
static char *init_prompt_base(void);
|
||||
static char *init_prompt(char *prompt_base);
|
||||
// pas static si utilisee par cd
|
||||
//static char *init_prompt(char *prompt_base);
|
||||
char *init_prompt(char *prompt_base);
|
||||
|
||||
//int init(t_all *c, char *envp[])
|
||||
int init(t_all *c, char **environ)
|
||||
@@ -37,7 +39,8 @@ int init(t_all *c, char **environ)
|
||||
return (1);
|
||||
}
|
||||
|
||||
// TODO : Un appel à builtin_export() modifiant $PATH doit aussi entrainer un appel à "c->path = retrieve_path()"
|
||||
// done : TODO : Un appel à builtin_export() modifiant $PATH doit aussi entrainer un appel à "c->path = retrieve_path()"
|
||||
// changer le prototype si utilise pas envp
|
||||
char **retrieve_path(char *envp[])
|
||||
{
|
||||
char *path;
|
||||
@@ -74,7 +77,8 @@ static char *init_prompt_base(void) // WIP, error return TODO
|
||||
return (prompt_base);
|
||||
}
|
||||
|
||||
static char *init_prompt(char *prompt_base) // WIP, error return TODO
|
||||
//static char *init_prompt(char *prompt_base) // WIP, error return TODO
|
||||
char *init_prompt(char *prompt_base) // WIP, error return TODO
|
||||
{
|
||||
char *prompt;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user