-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshell.c
More file actions
40 lines (39 loc) · 700 Bytes
/
shell.c
File metadata and controls
40 lines (39 loc) · 700 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
#include "shell.h"
/**
*main - our shell
*Return: 1 on fail 0 on success
*/
int main(void)
{
char *fPATH = NULL, *c = NULL, *buff = NULL;
char *PATH = NULL;
char **input;
int exit = 0;
signal(SIGINT, signal_to_handel);
PATH = _getenv("PATH");
if (PATH == NULL)
return (1);
do {
input = NULL;
if (isatty(STDIN_FILENO))
p_prompt();
buff = readline();
if (*buff != '\0')
{
input = make_token(buff);
if (input == NULL)
{
perror("Make Token Error");
free(buff);
continue;
}
fPATH = fpath(input, PATH, c);
if (builtins(input, buff, exit) != 0)
continue;
exit = execute(input, buff, fPATH);
}
else
free(buff);
} while (1);
return (0);
}