-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathminishell2.c
67 lines (60 loc) · 2.11 KB
/
minishell2.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* minishell2.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: aouchaad <aouchaad@student.1337.ma> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/06/23 15:30:38 by aouchaad #+# #+# */
/* Updated: 2023/06/23 15:52:20 by aouchaad ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
void controll_d_case(t_glob **glob, t_variables *var)
{
t_command_line *ctmp;
var->i = 0;
var->last_exit = (*glob)->exit_stat;
env_exp_free((*glob)->envp, (*glob)->export);
free_command_line((*glob)->command_line);
while ((*glob)->command_line)
{
ctmp = (*glob)->command_line->next;
free((*glob)->command_line);
(*glob)->command_line = NULL;
(*glob)->command_line = ctmp;
}
free((*glob));
(*glob) = NULL;
}
void split_input_and_ambg(char ***tokens, char **input, t_glob **glob)
{
(*tokens) = giga_splite((*input));
(*glob)->amb_red = 0;
expantion_ambiguous_redirect(tokens, (*glob));
if ((*glob)->amb_red == 0 && (*tokens) && (*tokens)[0] \
&& (*tokens)[0][0] != '\0')
call_exec_free_cmmline(glob, tokens);
}
int call_read_input(char **input, t_glob **glob, t_variables *var)
{
read_input(glob, var, input);
if ((*input) && ((*input)[0] == '\0' || only_spaces((*input)) == 1))
{
free_pointer(&(*input));
return (1);
}
return (0);
}
void exit_fun(t_variables *var)
{
write(1, "\nexit\n", 6);
exit (var->last_exit);
}
void add_histr_check_syn(char *input, t_variables *var, t_glob **glob)
{
add_history(input);
var->error = check_syntax(input);
if (var->error != 0)
(*glob)->exit_stat = 258;
}