aboutsummaryrefslogtreecommitdiff
path: root/src/repl.c
diff options
context:
space:
mode:
authorDominik Kaiser2025-01-20 20:14:32 +0100
committerGitHub2025-01-20 20:14:32 +0100
commitbd8c817797d5f2b1affe6957ffc51846a38e70ec (patch)
tree2fc0f567b1c4f2f168a931ad0bff69e52c6c226c /src/repl.c
parenta9aba07b52cbf98eb9c52cd8ee0cd5f5021d2931 (diff)
parentdc6a4f2d0de92984c2584ef905011e2a60792850 (diff)
downloadminishell-bd8c817797d5f2b1affe6957ffc51846a38e70ec.tar.gz
minishell-bd8c817797d5f2b1affe6957ffc51846a38e70ec.zip
Merge interpreter changes into main
Miau
Diffstat (limited to 'src/repl.c')
-rw-r--r--src/repl.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/repl.c b/src/repl.c
index 9fae849..16c8e95 100644
--- a/src/repl.c
+++ b/src/repl.c
@@ -6,35 +6,38 @@
/* By: chuhlig <chuhlig@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/06/24 16:07:04 by dkaiser #+# #+# */
-/* Updated: 2024/10/22 17:05:14 by chuhlig ### ########.fr */
+/* Updated: 2025/01/20 17:58:43 by dkaiser ### ########.fr */
/* */
/* ************************************************************************** */
#include "../include/minishell.h"
#include "token.h"
-void repl(const char *prompt, t_env **env)
+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)
- return ;
+ {
+ 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);
+ lines = parse(token_list, env);
if (lines)
- {
- print_ast(lines->content);
- eval(lines->content, env);
- }
+ set_return_code(eval(lines->content, env), env);
free(input);
}
}