forked from Teslothorcha/simple_shell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshell_.c
40 lines (35 loc) · 780 Bytes
/
shell_.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
#include "holberton.h"
/**
*main - The GATES OF SHELL!!
*@av: array of variadic arguments
*@ac: amount of variadic arguments
*Return: 0 on success
*/
int main(__attribute__ ((unused))int ac, char **av)
{
ssize_t bytes_l;
size_t numero_bytes;
char *cadena;
int l_ex = 0;
int counte = 0;
numero_bytes = 0;
cadena = NULL;
l_ex = s_length(EXIIT);
if (isatty(STDIN_FILENO))
write(STDOUT_FILENO, PROMPT, 2);
signal(SIGINT, handler);
while ((bytes_l = getline(&cadena, &numero_bytes, stdin) != EOF))
{
counte++;
if (_strcmpn(EXIIT, cadena, l_ex - 1) == 0)
break;
shell_1(&cadena, counte, av);
if (isatty(STDIN_FILENO))
write(STDOUT_FILENO, PROMPT, 2);
numero_bytes = 0;
free(cadena);
cadena = NULL;
}
free(cadena);
return (EXIT_SUCCESS);
}