-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenv.c
More file actions
39 lines (37 loc) · 674 Bytes
/
env.c
File metadata and controls
39 lines (37 loc) · 674 Bytes
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
#include "headers.h"
#include "env.h"
void set(char *inputs[], int args)
{
if (args == 2)
{
if (setenv(inputs[1], " ", 1) < 0)
{
perror("setenv");
}
}
else if (args == 3)
{
if (setenv(inputs[1], inputs[2], 1) < 0)
{
perror("setenv");
}
}
else
{
fprintf(stderr, "ERROR: Incorrent number of arguments\n");
}
}
void unset(char *inputs[], int args)
{
if (args == 2)
{
if (unsetenv(inputs[1]) < 0)
{
perror("unsetenv");
}
}
else
{
fprintf(stderr, "ERROR: Incorrent number of arguments\n");
}
}