-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuiltin.c
More file actions
76 lines (62 loc) · 1.36 KB
/
builtin.c
File metadata and controls
76 lines (62 loc) · 1.36 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include "main.h"
int call_echo(char **args){
int start = 1;
bool newline = true;
if (!args || !args[0])
return (1);
if (args[1] && !strcmp(args[1], "-n"))
{
newline = false;
start = 2;
}
for (int i = start; args[i]; i++)
{
printf("%s", args[i]);
if (args[i + 1])
printf(" ");
}
if (newline)
printf("\n");
return (0);
}
int call_env(char **args){
extern char **environ;
(void)args;
if (!environ)
return (1);
for (int i = 0; environ[i]; i++)
printf("%s\n", environ[i]);
return (0);
}
int call_exit(char **args){
(void)args;
dbzSpinnerLoading();
exit(EXIT_SUCCESS);
}
void dbzSpinnerLoading() {
const char *charging[] = {
"[ ]",
"[= ]",
"[== ]",
"[=== ]",
"[==== ]",
"[===== ]",
"[====== ]",
"[======= ]",
"[======== ]",
"[========= ]",
"[========== ]",
"[=========== ]",
"[===========💥]",
};
const int frames = sizeof(charging) / sizeof(charging[0]);
printf("Shutting down...\n");
// Loop through the "charging" animation for 3 seconds
for (int i = 0; i < frames; i++) {
printf("\r %s", charging[i]);
fflush(stdout); // Force update the console
usleep(421337);
}
printf("\n✅ EXIT ✅\n");
exit(EXIT_SUCCESS);
}