unset ok
This commit is contained in:
@@ -4,6 +4,7 @@
|
|||||||
- init.c
|
- init.c
|
||||||
- minishell_structs.h
|
- minishell_structs.h
|
||||||
- export.c
|
- export.c
|
||||||
|
- subshell_exec.c
|
||||||
|
|
||||||
|
|
||||||
## TESTS SIGNAUX WITH HERE-DOCS :
|
## TESTS SIGNAUX WITH HERE-DOCS :
|
||||||
|
|||||||
@@ -3,27 +3,21 @@
|
|||||||
|
|
||||||
int builtin_unset(int argc, char *argv[], t_all *c)
|
int builtin_unset(int argc, char *argv[], t_all *c)
|
||||||
{
|
{
|
||||||
int position;
|
|
||||||
extern char **environ;
|
extern char **environ;
|
||||||
|
int env_position;
|
||||||
|
|
||||||
(void)argc;
|
(void)argc;
|
||||||
(void)c;
|
(void)c;
|
||||||
//position = getenv_position(c->envp, argv[1]);
|
env_position = getenv_position(environ, argv[1]);
|
||||||
position = getenv_position(environ, argv[1]);
|
if (environ[env_position] == '\0')
|
||||||
if (position == -1)
|
|
||||||
return (0);
|
return (0);
|
||||||
// while (c->envp[position])
|
while (environ[env_position + 1])
|
||||||
while (environ[position])
|
|
||||||
{
|
{
|
||||||
write(1, "1", 1);
|
free(environ[env_position]);
|
||||||
//free(c->envp[position]);
|
environ[env_position] = ft_strdup(environ[env_position + 1]);
|
||||||
free(environ[position]);
|
env_position++;
|
||||||
//c->envp[position] = ft_strdup(c->envp[position + 1]);
|
|
||||||
environ[position] = ft_strdup(environ[position + 1]);
|
|
||||||
position++;
|
|
||||||
}
|
}
|
||||||
write(1, "2", 1);
|
free(environ[env_position]);
|
||||||
//free(c->envp[position]);
|
environ[env_position] = NULL;
|
||||||
free(environ[position]);
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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/25 18:57:59 by hulamy ### ########.fr */
|
/* Updated: 2021/11/25 19:47:00 by hulamy ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -25,7 +25,7 @@ int init(t_all *c, char **environ)
|
|||||||
// if (!c->envp)
|
// if (!c->envp)
|
||||||
// return (ft_reti_perror(0, "ft_dup_2d_char_arr(envp) error"));
|
// return (ft_reti_perror(0, "ft_dup_2d_char_arr(envp) error"));
|
||||||
//print_matrix(c->envp, "\n --- \n"); // TEST WIP
|
//print_matrix(c->envp, "\n --- \n"); // TEST WIP
|
||||||
//c->path = retrieve_path(c->envp); // No return check. Its intended. PATH is optional
|
// c->path = retrieve_path(c->envp); // No return check. Its intended. PATH is optional
|
||||||
c->path = retrieve_path(environ); // No return check. Its intended. PATH is optional
|
c->path = retrieve_path(environ); // No return check. Its intended. PATH is optional
|
||||||
c->prompt_base = init_prompt_base();
|
c->prompt_base = init_prompt_base();
|
||||||
if (!c->prompt_base)
|
if (!c->prompt_base)
|
||||||
|
|||||||
@@ -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/25 16:30:24 by hulamy ### ########.fr */
|
/* Updated: 2021/11/25 19:48:07 by hulamy ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
(void)argc;
|
(void)argc;
|
||||||
(void)argv;
|
(void)argv;
|
||||||
//if (!init(&c, envp))
|
// if (!init(&c, envp))
|
||||||
if (!init(&c, environ))
|
if (!init(&c, environ))
|
||||||
free_exit(&c, EXIT_FAILURE);
|
free_exit(&c, EXIT_FAILURE);
|
||||||
//putenv("VAR=W1 W2 W3"); // TEMP TEST
|
//putenv("VAR=W1 W2 W3"); // TEMP TEST
|
||||||
|
|||||||
Reference in New Issue
Block a user