-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathminishell.c
58 lines (53 loc) · 1.57 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
53
54
55
56
57
58
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* minishell.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tumolabs <tumolabs@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/17 03:27:33 by dmartiro #+# #+# */
/* Updated: 2023/01/18 22:20:16 by tumolabs ### ########.fr */
/* */
/* ************************************************************************** */
#include "includes/minishell_header.h"
char *ft_readline(char *line)
{
char *cmd;
cmd = NULL;
cmd = readline(line);
if (!cmd)
{
ft_putstr_fd("exit\n", 1);
exit(0);
}
if (cmd[0])
add_history(cmd);
return (cmd);
}
int main(int argc, char *argv[], char *envp[])
{
t_table *table;
t_cmdline *tree;
char *cmdline;
(void)argv;
(void)argc;
tree = NULL;
table = NULL;
bash_setup(&table, envp);
ft_signal(0);
while (1)
{
cmdline = ft_readline("Minishell-$ ");
if (!cmdline[0])
handleterm(0);
if (lexical_analyzer(cmdline, table))
{
syntax_error(table);
tree = parse_tree(table);
execution(&tree, &table);
update_table(tree, table);
}
free(cmdline);
}
return (0);
}