-
Notifications
You must be signed in to change notification settings - Fork 2
/
minishell.c
52 lines (46 loc) · 1.61 KB
/
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* minishell.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: smischni <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/08/10 18:14:26 by smischni #+# #+# */
/* Updated: 2022/08/10 18:14:28 by smischni ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
int g_exit_status = 0;
int main(int argc, char **argv, char **envp)
{
t_data *data;
(void)argc;
(void)argv;
data = initialiser(envp);
data->to_env_list = create_env_list(envp);
signal(SIGINT, signal_handler_parent);
signal(SIGQUIT, SIG_IGN);
while (1)
{
data->lexar = NULL;
data->line = readline("minishell:> ");
if (data->line == NULL)
break ;
add_history(data->line);
if (parser(data, &data->line))
executor(data);
if (data->line)
free(data->line);
}
if (data->to_env_list)
ft_lstclear_env(&data->to_env_list, free);
exit(g_exit_status);
}
/* Initialises All Data */
t_data *initialiser(char **envp)
{
t_data *data;
(void)envp;
data = ft_calloc(1, sizeof(t_data));
return (data);
}