-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexec_minishell.c
80 lines (72 loc) · 1.98 KB
/
exec_minishell.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* exec_minishell.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mghalmi <mghalmi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/08/05 03:16:50 by mghalmi #+# #+# */
/* Updated: 2023/08/19 20:05:07 by mghalmi ### ########.fr */
/* */
/* ************************************************************************** */
#include "Minishell.h"
void for_exec(t_node *node, t_env *new_envp)
{
execution(node, new_envp);
if (g_test == -1)
update_status(1, new_envp, 1);
}
void for_qudespars(t_env *new_envp, char *input)
{
ft_putstr_fd("syntax error close qudes\n", 2);
update_status(258, new_envp, 0);
free(input);
}
t_node *in_hist(char *input, t_env *new_envp, int *ret)
{
return (inputs(input, env_exec(new_envp), ret));
}
int to_con(char *input, t_env *new_envp)
{
int i;
i = 0;
add_history(input);
if (input[0] == '\0')
{
free(input);
i = 1;
}
if (qudespars(input) == 0)
{
for_qudespars(new_envp, input);
i = 1;
}
return (i);
}
void execute_minishell(t_env *new_envp)
{
t_node *node;
char *input;
int ret;
ret = 0;
node = NULL;
while (1)
{
input = get_user_input(node, new_envp);
if (!input)
exit_main(new_envp);
if (to_con(input, new_envp))
continue ;
node = in_hist(input, new_envp, &ret);
if (node == NULL)
{
update_status(258, new_envp, 0);
continue ;
}
if (ret != -1)
for_exec(node, new_envp);
for_stats(new_envp, node, ret);
free_node(node);
ft___pwd(new_envp);
}
}