-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtesting.c
More file actions
51 lines (49 loc) · 884 Bytes
/
testing.c
File metadata and controls
51 lines (49 loc) · 884 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
40
41
42
43
44
45
46
47
48
49
50
51
#include "header.h"
/**
*main - get commands to execute
*@ac: number of arguments unused
*@ar: arguments unused
*@envp: environment
*Return: nothing
*/
int main(int ac, char *ar[], char *envp[])
{
(void)envp;
(void)ac;
(void)ar;
char *buffer = NULL, *av[] = {NULL};
int pos = 0, g = 0;
size_t size = 0;
do {
pos = 0;
if (isatty(STDIN_FILENO))
printf("#cisfun$ ");
g = getline(&buffer, &size, stdin);
if (!buffer)
free(buffer);
if (g == EOF)
{
if (isatty(STDIN_FILENO))
write(STDOUT_FILENO, "\n", 1);
free(buffer);
exit(0);
}
if (strcmp(buffer, "exit\n") == 0)
{ free(buffer);
exit(0);
}
if (strcmp(buffer, "env\n") == 0)
print_e(envp);
_split(buffer, av);
if ((*buffer != '\n') && av[0])
_exec(av);
while (pos < 10)
{
pos++;
}
} while (1);
free(buffer);
free(av);
free(envp);
return (EXIT_SUCCESS);
}