Dev (#2)
* Restart from scratch branched out on dev removed all previous source files started test on new env2lst function * norm: splitted functions in main into appropriate file Moved lstdelenvelem & env2lst to ms_env.c Normed out files * Feat(WIP): Added possibility to cmd_env to execute commands with altered env. Added dummy function for cd, echo, setenv & unsetenv Started work on env copy feature * feature: switched env from ft_list to specific list * feature: added execution of commands from path * feature: added env, setenv & unsetenv builtins added -i option & command execution to env added setenv & unsetenv builtins * Clean-up: normed out files * Changed comportment on error for check_path functions * feature: added completion for ~ and ${} WIP leaks detected on ${} completion * fix leak on ext need test * feature: added echo cmd changed printf ref to ft_printf * feature: add cd built-in * Simple norm-out * moved env functions to libft * fixed out-of-memory access in extension * Resolved infinite loop in extension revolving WIP norming in cd * Normedout cmd_cd.c * Normed out functions in cmd_cd * Normed out funtions sorting out needed * removed -fsanitize from Makefile * corrected env -i crash & SHLVL * Delete norm.txt * added put_error_cd2 in put_error_cd.c * added inline environment
This commit is contained in:
@@ -5,17 +5,35 @@
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/01/15 14:58:05 by tmaze #+# #+# */
|
||||
/* Updated: 2019/01/15 15:04:05 by tmaze ### ########.fr */
|
||||
/* Created: 2019/09/20 14:42:01 by tmaze #+# #+# */
|
||||
/* Updated: 2019/11/10 15:52:09 by tmaze ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "minishell.h"
|
||||
|
||||
int cmd_unsetenv(char **argv, t_list **env)
|
||||
int cmd_unsetenv(char **argv, t_env **env)
|
||||
{
|
||||
if (argv[1] == NULL)
|
||||
return (-1);
|
||||
env_delelem(argv[1], env);
|
||||
return (0);
|
||||
t_env **it;
|
||||
t_env *tmp;
|
||||
|
||||
it = env;
|
||||
if (!argv[1])
|
||||
{
|
||||
ft_printf("usage: unsetenv [KEY]\n");
|
||||
return (1);
|
||||
}
|
||||
while (*it)
|
||||
{
|
||||
if (ft_strequ((*it)->key, argv[1]))
|
||||
{
|
||||
tmp = *it;
|
||||
*it = tmp->next;
|
||||
ft_envdelelem(&tmp);
|
||||
return (0);
|
||||
}
|
||||
it = &((*it)->next);
|
||||
}
|
||||
ft_printf("Entry %s not found\n", argv[1]);
|
||||
return (1);
|
||||
}
|
||||
|
Reference in New Issue
Block a user