-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshell.c
More file actions
46 lines (42 loc) · 716 Bytes
/
Copy pathshell.c
File metadata and controls
46 lines (42 loc) · 716 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
#include <limits.h>
#include <stdio.h>
#include "shell.h"
/**
* main - Entry point
* @av: argument vector
* @ac: count of arguments
* Description: a UNIX command line interpreter.
* Return: Always 0 (Success)
*/
int main(int ac, char **av)
{
char *line;
char **args;
int status;
(void)ac;
/*if (ac < 1)*/
/*return (-1);*/
do {
if (isatty(STDIN_FILENO))
{
write(1, "(monsh $)", 9);
}
line = read_line();
if (line == NULL)
{
perror(av[0]);
exit(EXIT_FAILURE);
}
args = split_line(line);
if (args == NULL)
{
free(line);
perror(av[0]);
exit(EXIT_FAILURE);
}
status = execute_command(args, av[0]);
free(line);
free(args);
} while (status);
return (0);
}