-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
40 lines (37 loc) · 1.52 KB
/
main.c
File metadata and controls
40 lines (37 loc) · 1.52 KB
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: samy_bravy <samy_bravy@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/30 13:47:54 by fgrisost #+# #+# */
/* Updated: 2024/08/31 10:28:47 by samy_bravy ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
int main(int argc, char **argv, char **env)
{
t_main_vars vars;
t_list *lst_env;
int exit_status;
g_signal = 0;
exit_status = 0;
(void)argc;
(void)argv;
take_history(&vars);
lst_env = ft_matrix_to_lst(env);
if (ft_getenv("OLDPWD", lst_env) == NULL)
ft_export("OLDPWD", &lst_env, 0);
vars.tmp = dup(STDIN_FILENO);
dup2(vars.tmp, STDIN_FILENO);
close(vars.tmp);
vars.tmp = dup(STDOUT_FILENO);
dup2(vars.tmp, STDOUT_FILENO);
close(vars.tmp);
shell_loop(&vars, &exit_status, &lst_env);
close(STDIN_FILENO);
close(STDOUT_FILENO);
ft_lstclear(&lst_env, free);
return (exit_status);
}