-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuiltin.c
More file actions
39 lines (37 loc) · 686 Bytes
/
builtin.c
File metadata and controls
39 lines (37 loc) · 686 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 "shell.h"
/**
* builtin_c - match and execuute builtin
* @toks: typed command
* @env: variables
* @n: error massage
* @command: command
* Return: 1 or 0
*/
int builtin_c(char **toks, list_t *env, int n, char **command)
{
if (_strcmp(toks[0], "exit") == 0)
{
return (sh_exit(toks, command, env, n));
}
else if (_strcmp(toks[0], "cd") == 0)
{
ch_cd(toks, &env, n);
return (1);
}
else if (_strcmp(toks[0], "env") == 0)
{
print_env(toks, env);
return (0);
}
else if (_strcmp(toks[0], "setenv") == 0)
{
sh_setenv(&env, toks);
return (1);
}
else if (_strcmp(toks[0], "unsetenv") == 0)
{
sh_unsetenv(&env, toks);
return (1);
}
return (0);
}