blob: 15b0a8008d6dd1e816d7330c9a9f7dd4ac95593a (
plain)
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
|
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* repl.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: chuhlig <chuhlig@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/06/24 16:07:04 by dkaiser #+# #+# */
/* Updated: 2025/01/20 12:45:00 by chuhlig ### ########.fr */
/* */
/* ************************************************************************** */
#include "../include/minishell.h"
#include "token.h"
void repl(const char *prompt, t_env **env, int *promptflag)
{
char *input;
t_token *token_list;
t_list *lines;
(*promptflag)++;
while (1)
{
input = readline(prompt);
if (input == NULL)
{
if (*promptflag > 1)
(*promptflag)--;
printf("exit\n");
break ;
}
if (input[0] == '\0')
continue ;
add_history(input);
token_list = NULL;
tokenizer(input, &token_list, '\0');
lines = parse(token_list, env);
if (lines)
set_return_code(eval(lines->content, env), env);
free(input);
}
}
//echo hi | >./outfiles/outfile01 echo bye >./test_files/invalid_permission
|