-
Notifications
You must be signed in to change notification settings - Fork 0
/
commands.c
63 lines (45 loc) · 1.37 KB
/
commands.c
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
57
58
59
60
61
62
63
#include "headers.h"
int interpretCommands(char ** commands, char HOME_DIRECTORY[], int processes[], int *sz_proc)
{
int exit = 0;
if(!strcmp(commands[0], "echo"))
shell_echo(commands);
else if(!strcmp(commands[0], "cd"))
shell_cd(commands, HOME_DIRECTORY);
else if(!strcmp(commands[0], "pwd"))
shell_pwd();
else if(!strcmp(commands[0], "exit"))
exit = 1;
else if(!strcmp(commands[0], "quit"))
exit = 1;
else if(!strcmp(commands[0], "remindme"))
reminder(commands);
else if(!strcmp(commands[0], "pinfo"))
{
if(commands[1] != NULL)
shell_pinfo(atoi(commands[1]), HOME_DIRECTORY);
else
shell_pinfo(getpid(), HOME_DIRECTORY);
}
else if(!strcmp(commands[0], "ls"))
shell_ls(commands, HOME_DIRECTORY);
else if(!strcmp(commands[0], "clock"))
shell_clock(commands);
else if(!strcmp(commands[0], "setenv"))
setenvir(commands);
else if(!strcmp(commands[0], "unsetenv"))
unsetenvir(commands);
else if(!strcmp(commands[0], "jobs"))
shell_jobs(commands, processes);
else if(!strcmp(commands[0], "kjobs"))
shell_kjobs(commands, processes);
else if(!strcmp(commands[0], "fg"))
shell_fg(commands, processes, sz_proc);
else if(!strcmp(commands[0], "bg"))
shell_bg(commands, processes);
else if(!strcmp(commands[0], "overkill"))
shell_overkill(commands, processes);
else
other_commands(commands, processes, sz_proc);
return exit;
}