This commit is contained in:
hugogogo
2021-11-25 21:33:46 +01:00
parent ef3e91be13
commit ac11eee947
4 changed files with 14 additions and 19 deletions

View File

@@ -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);
}

View File

@@ -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)

View File

@@ -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