-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
54 lines (49 loc) · 1.54 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
54
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ktashbae <[email protected]. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/11 15:45:54 by hoomen #+# #+# */
/* Updated: 2022/10/29 17:46:43 by ktashbae ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
bool isempty(char *buf)
{
int i;
if (*buf == '\0')
return (true);
i = -1;
while (buf[++i])
{
if (buf[i] != ' ' && buf[i] != '\t')
return (false);
}
return (true);
}
int main(int argc, char **argv, char **envp)
{
char *buf;
t_minishell minishell;
(void)argc;
(void)argv;
g_global_exit_status = 0;
init_minishell(&minishell, envp);
buf = NULL;
while (1)
{
signals_interactive_mode(&(minishell.termios_cpy));
free(buf);
buf = readline("Minishell>>> ");
if (buf == NULL)
break ;
if (isempty(buf))
continue ;
main_executor(buf, &minishell);
add_history(buf);
}
clear_history();
mini_exit(0, NULL, &minishell);
}