blob: 367f06312f69964ad283993476a9153eb9b806a9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* unset.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: charles <charles@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/01 17:10:51 by charles #+# #+# */
/* Updated: 2020/07/19 18:47:36 by charles ### ########.fr */
/* */
/* ************************************************************************** */
/*
** \file unset.c
** \brief `unset` builtin
*/
#include "minishell.h"
int builtin_unset(char **argv, t_env env)
{
size_t i;
int found_index;
int status;
status = 0;
i = 0;
while (argv[++i] != NULL)
{
if (!utils_valid_identifier(argv[i]))
{
errorf("unset: `%s': not a valid identifier\n", argv[i]);
status = 1;
continue; // put invalid identifier
}
found_index = env_search_index(env, argv[i]);
if (found_index == -1)
continue;
ft_vecremove(env, found_index, free);
}
return (status);
}
|