-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommand_execution_aux.c
More file actions
57 lines (52 loc) · 1.23 KB
/
command_execution_aux.c
File metadata and controls
57 lines (52 loc) · 1.23 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include "shell.h"
/**
* execute_cd - Executes the 'cd' command
* @args: The arguments for the 'cd' command
* @env: A pointer to the environment variables array
*/
void execute_cd(char **args, char **env)
{
execute_cd_command(args, env);
}
/**
* execute_env - Executes the 'env' command
* @args: The arguments for the 'env' command
* @env: A pointer to the environment variables array
*/
void execute_env(char **args, char **env)
{
(void)args;
print_env(env);
}
/**
* execute_setenv - Executes the 'setenv' command
* @args: The arguments for the 'setenv' command
* @env: A pointer to the environment variables array
*/
void execute_setenv(char **args, char **env)
{
if (args[1] && args[2]) /* Check if VARIABLE and VALUE are provided */
{
set_env_var(args[1], args[2], &env);
}
else
{
write(STDERR_FILENO, "Usage: setenv VARIABLE VALUE\n", 29);
}
}
/**
* execute_unsetenv - Executes the 'unsetenv' command
* @args: The arguments for the 'unsetenv' command
* @env: A pointer to the environment variables array
*/
void execute_unsetenv(char **args, char **env)
{
if (args[1]) /* Check if VARIABLE is provided */
{
unset_env_var(args[1], &env);
}
else
{
write(STDERR_FILENO, "Usage: unsetenv VARIABLE\n", 25);
}
}