-
Notifications
You must be signed in to change notification settings - Fork 0
/
main2.c
58 lines (53 loc) · 1.74 KB
/
main2.c
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
47
48
49
50
51
52
53
54
55
56
57
58
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main2.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ler-rech <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/02/20 12:32:27 by hrhirha #+# #+# */
/* Updated: 2021/03/18 16:08:00 by ler-rech ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
int commands_loop2(t_minishell *minishell, t_list *my_pipe)
{
int status;
t_command *command;
status = 1;
command = (t_command *)my_pipe->content;
status = loop_redirections(minishell, command);
if (status < 0)
return (1);
status = shell_execute(minishell, command);
if (status == 0)
return (0);
reset_std(minishell);
return (1);
}
int pipes_loop(t_minishell *minishell)
{
t_list *current;
int status;
t_list *my_pipe;
status = 1;
current = minishell->cmds;
while (current != NULL)
{
my_pipe = current->content;
scan_command(my_pipe, minishell->env);
if (my_pipe->next == NULL)
status = commands_loop2(minishell, my_pipe);
else
status = commands_loop(minishell, my_pipe);
if (status < 0)
{
g_exist.last_exec = 1;
return (1);
}
else if (status == 0)
return (0);
current = current->next;
}
return (1);
}