maxishell
Implementation of a shell for Linux-like systems
Loading...
Searching...
No Matches
unset.c
Go to the documentation of this file.
1
/* ************************************************************************** */
2
/* */
3
/* ::: :::::::: */
4
/* unset.c :+: :+: :+: */
5
/* +:+ +:+ +:+ */
6
/* By: dmdemirk <dmdemirk@student.42london.c +#+ +:+ +#+ */
7
/* +#+#+#+#+#+ +#+ */
8
/* Created: 2024/06/17 11:10:03 by dmdemirk #+# #+# */
9
/* Updated: 2024/09/06 12:01:39 by dmdemirk ### ########.fr */
10
/* */
11
/* ************************************************************************** */
12
13
#include "
shell.h
"
14
#include "
env.h
"
15
#include "
libft.h
"
16
#include <unistd.h>
17
#include "
exit_status.h
"
18
19
#include <stdio.h>
20
21
/*
22
todo
23
set the exit status to ERROR if the variable is not a valid identifier
24
Functionality:
25
- Unset the environment variable
26
- Return ERROR if the variable is not a valid identifier
27
*/
28
29
int
builtin_unset
(
t_ms_data
*data)
30
{
31
int
i;
32
char
*key;
33
34
i = 0;
35
while
(data->
args
[++i])
36
{
37
key = data->
args
[i];
38
if
(
unset_env
(&data->
envp
, key) == -1)
39
{
40
return
(
EXIT_SUCCESS
);
41
}
42
}
43
return
(
EXIT_SUCCESS
);
44
}
env.h
unset_env
int unset_env(t_env **env, const char *name)
Definition
env.c:95
exit_status.h
EXIT_SUCCESS
#define EXIT_SUCCESS
Definition
exit_status.h:16
libft.h
shell.h
s_ms_data
Definition
shell.h:21
s_ms_data::envp
t_env * envp
Definition
shell.h:24
s_ms_data::args
char ** args
Definition
shell.h:23
builtin_unset
int builtin_unset(t_ms_data *data)
Definition
unset.c:29
src
builtins
unset.c
Generated by
1.9.8