diff options
| author | Dominik Kaiser | 2025-01-14 18:32:42 +0100 |
|---|---|---|
| committer | GitHub | 2025-01-14 18:32:42 +0100 |
| commit | d4f3525a01f2566afed0da9209cb1c64bf188776 (patch) | |
| tree | 14d1f541418576d565f42f0d70faf1369fc17d1b /src/repl.c | |
| parent | 3e692dac63577011bd5862a66767ef412183f26b (diff) | |
| parent | da80405b345b58f9e1bd83039b1df3771b5ca193 (diff) | |
| download | minishell-d4f3525a01f2566afed0da9209cb1c64bf188776.tar.gz minishell-d4f3525a01f2566afed0da9209cb1c64bf188776.zip | |
Merge branch 'miau' into uwu
Diffstat (limited to 'src/repl.c')
| -rw-r--r-- | src/repl.c | 36 |
1 files changed, 9 insertions, 27 deletions
@@ -6,56 +6,38 @@ /* By: chuhlig <chuhlig@student.42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/06/24 16:07:04 by dkaiser #+# #+# */ -/* Updated: 2025/01/14 14:53:29 by dkaiser ### ########.fr */ +/* Updated: 2025/01/14 15:39:58 by chuhlig ### ########.fr */ /* */ /* ************************************************************************** */ #include "../include/minishell.h" #include "token.h" -t_token *reverse_token_list(t_token *head) -{ - t_token *prev; - t_token *current; - t_token *next; - - prev = NULL; - current = head; - next = NULL; - while (current != NULL) - { - next = current->previous; - current->next = prev; - current->previous = next; - prev = current; - current = next; - } - return (prev); -} - -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'); - token_list = reverse_token_list(token_list); lines = parse(token_list, env); if (lines) - { - print_ast(lines->content); set_return_code(eval(lines->content, env), env); - } free(input); } } |
