save commit

This commit is contained in:
2026-02-09 20:47:43 +01:00
parent e983f7fe64
commit 280fa51f94
39 changed files with 3400 additions and 239 deletions

View File

@@ -0,0 +1,46 @@
#include "minishell.h"
static void handle_line(t_shell *sh, char *line)
{
int error = 0;
t_token *toks = NULL;
t_pipeline *p = NULL;
toks = lex_line(line, &error);
if (error)
{
free_tokens(toks);
return;
}
p = parse_tokens(toks, &error);
free_tokens(toks);
if (error || !p)
{
free_pipeline(p);
return;
}
if (expand_pipeline(p, sh) != 0)
{
free_pipeline(p);
return;
}
sh->exit_status = execute_pipeline(p, sh);
sh->last_status = sh->exit_status;
free_pipeline(p);
}
void ms_loop(t_shell *sh)
{
char *line;
while (!sh->exit_requested)
{
line = readline(MS_PROMPT);
if (!line)
break;
if (line[0] != '\0')
add_history(line);
handle_line(sh, line);
free(line);
}
}