-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
52 lines (47 loc) · 694 Bytes
/
main.c
File metadata and controls
52 lines (47 loc) · 694 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 "main.h"
/**
* main - Entry point of c programs
*
* Return: 0 on success
*/
int main(void)
{
/* main function with while loop of our shell */
sh_t data;
int pl;
_memset(&data, 0, sizeof(data));
signal(SIGINT, signal_handler);
while (true)
{
index_cmd(&data);
if (read_line(&data) < 0)
{
if (isatty(STDIN_FILENO))
PRINT("\n");
break;
}
if (split_line(&data) < 0)
{
free_data(&data);
continue;
}
pl = parse_line(&data);
if (pl == 0)
{
free_data(&data);
continue;
}
if (pl < 0)
{
print_error(&data);
continue;
}
if (execute(&data) < 0)
{
print_error(&data);
break;
}
}
free_data(&data);
return (0);
}