-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshell.c
More file actions
39 lines (37 loc) · 721 Bytes
/
shell.c
File metadata and controls
39 lines (37 loc) · 721 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
#include "shell.h"
/**
* main - Entry point of the shell program
* @argc: Number of command-line arguments
* @argv: Array of command-line arguments
*
* Return: EXIT_SUCCESS upon successful completion
*/
int main(int argc, char *argv[])
{
char *input, **args, *progname = argv[0];
int interactive = isatty(STDIN_FILENO);
(void)argc;
signal(SIGINT, SIG_DFL);
while (1)
{
if (interactive)
{
write(STDOUT_FILENO, "$ ", 2);
fflush(stdout);
}
input = read_line();
if (input == NULL)
{
if (interactive)
{
write(STDOUT_FILENO, "\n", 1);
}
free(input);
break;
}
args = split_input(input);
cmd_check(args, progname);
free_memory(input, args);
}
return (EXIT_SUCCESS);
}