-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
53 lines (49 loc) · 1.55 KB
/
main.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jaehejun <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/10/24 15:46:53 by jaehejun #+# #+# */
/* Updated: 2023/10/27 17:44:39 by jaehejun ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
int g_exit_status;
int main(int argc, char **argv, char **envp)
{
(void)argc;
(void)argv;
(void)envp;
char *line;
char **tokens;
g_exit_status = 0;
while (1)
{
rl_catch_signals = 0;
signal(SIGINT, sigint_handler);
signal(SIGQUIT, SIG_IGN);
line = readline("myshell$ ");
if (line == NULL)
{
printf("\033[1A\033[9Cexit\n");
g_exit_status = 0;
exit(0);
}
if (line[0] != '\0')
{
add_history(line);
if (check_quotes(line) == 0) // ' 또는 " 홀수 -> unclosed quotes
{
printf("quote is not closed\n");
free(line);
g_exit_status = 1;
continue ;
}
else
tokens = tokenize_line(line);
}
}
return (0);
}