unset ok
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
- init.c
|
||||
- minishell_structs.h
|
||||
- export.c
|
||||
- subshell_exec.c
|
||||
|
||||
|
||||
## TESTS SIGNAUX WITH HERE-DOCS :
|
||||
|
||||
@@ -3,27 +3,21 @@
|
||||
|
||||
int builtin_unset(int argc, char *argv[], t_all *c)
|
||||
{
|
||||
int position;
|
||||
extern char **environ;
|
||||
int env_position;
|
||||
|
||||
(void)argc;
|
||||
(void)c;
|
||||
//position = getenv_position(c->envp, argv[1]);
|
||||
position = getenv_position(environ, argv[1]);
|
||||
if (position == -1)
|
||||
env_position = getenv_position(environ, argv[1]);
|
||||
if (environ[env_position] == '\0')
|
||||
return (0);
|
||||
// while (c->envp[position])
|
||||
while (environ[position])
|
||||
while (environ[env_position + 1])
|
||||
{
|
||||
write(1, "1", 1);
|
||||
//free(c->envp[position]);
|
||||
free(environ[position]);
|
||||
//c->envp[position] = ft_strdup(c->envp[position + 1]);
|
||||
environ[position] = ft_strdup(environ[position + 1]);
|
||||
position++;
|
||||
free(environ[env_position]);
|
||||
environ[env_position] = ft_strdup(environ[env_position + 1]);
|
||||
env_position++;
|
||||
}
|
||||
write(1, "2", 1);
|
||||
//free(c->envp[position]);
|
||||
free(environ[position]);
|
||||
free(environ[env_position]);
|
||||
environ[env_position] = NULL;
|
||||
return (0);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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)
|
||||
// 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->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->prompt_base = init_prompt_base();
|
||||
if (!c->prompt_base)
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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)argv;
|
||||
//if (!init(&c, envp))
|
||||
// if (!init(&c, envp))
|
||||
if (!init(&c, environ))
|
||||
free_exit(&c, EXIT_FAILURE);
|
||||
//putenv("VAR=W1 W2 W3"); // TEMP TEST
|
||||
|
||||
Reference in New Issue
Block a user