-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
44 lines (44 loc) · 709 Bytes
/
Copy pathmain.c
File metadata and controls
44 lines (44 loc) · 709 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
#include "myshell.h"
/**
* main -shell entry point;
* @ac: number of command line arguments
* @argv: An array of command line argument
* Return: zero on success,and in faulure non-zero
*/
int main(int ac, char **argv)
{
char *input;
int x, y;
char **cmd;
size_t n;
ssize_t read_no;
int status;
(void) ac;
status = 0;
cmd = NULL;
while (1)
{
prompt();
input = NULL;
n = 0;
read_no = mygetline(&input, &n);
if (read_no == -1)
{
free(input);
if (isatty(STDIN_FILENO) == 1)
write(STDOUT_FILENO, "\n", 1);
return (status);
}
cmd = tokener(input);
if (cmd == NULL)
continue;
x = str_compare(cmd[0], "exit");
if (x == 0)
{
y = myexit(cmd);
return (y);
}
status = cmd_excuter(cmd, argv[0]);
}
return (0);
}