-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
46 lines (40 loc) · 793 Bytes
/
main.c
File metadata and controls
46 lines (40 loc) · 793 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
46
#include "shell.h"
/**
* main- function to show simple shell
* @c: number of arguments
* @argv: vector of arguments
* @env: gets the value of an environ variable
* Return: 0 Always (success)
*/
int main(int c, char **argv, char **env)
{
char *order = NULL;
char **order_words = NULL;
int stat = 0, flag = 1, ix = 0;
(void)c;
while (flag)
{
int l;
int n;
order = habiba_read();
if (order == NULL)
{
if (isatty(STDOUT_FILENO) == 1)
{
fflush(STDIN_FILENO);
write(STDOUT_FILENO, "\n", 1);
}
return (stat); }
ix++;
order_words = abdelhamid_tokin(order, &n);
if (!order_words)
{
continue; }
l = bulit_in(order_words[0], env);
if (l)
free_the_array(order_words);
else
stat = _execv(order_words, n, argv, ix);
}
return (0);
}