Skip to content

Commit

Permalink
Co-authored-by: Roman Mikhaylenko <roman.mikhaylenko14@gmail.com>
Browse files Browse the repository at this point in the history
  • Loading branch information
dimadem committed Jun 28, 2024
1 parent 7e82605 commit 88024db
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
10 changes: 5 additions & 5 deletions src/execute/execute.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,27 +42,27 @@ int execute_ast(t_ast *node, t_minishell_data *data)
data->args = node->args;
return (execute(data));
}
else if (node->type == ENV_VAR)
else if (node->type == ENV_VAR) // "$()"
{
printf(BLU"ENV_VAR\n"RESET);
//execute_redirect(node, data);
}
else if (node->type == REDIR_IN)
{
printf(CYA"REDIR_IN\n"RESET);
printf(CYA"REDIR_IN\n"RESET); // "<"
//execute_sequence(node, data);
}
else if (node->type == REDIR_OUT)
else if (node->type == REDIR_OUT) // ">"
{
printf(CYA"REDIR_OUT\n"RESET);
//execute_sequence(node, data);
}
else if (node->type == REDIR_APPEND)
else if (node->type == REDIR_APPEND) // ">>"
{
printf(CYA"REDIR_APPEND\n"RESET);
//execute_sequence(node, data);
}
else if (node->type == REDIR_HEREDOC)
else if (node->type == REDIR_HEREDOC) // "<<"
{
printf(MAG"REDIR_HEREDOC\n"RESET);
//execute_sequence(node, data);
Expand Down
23 changes: 17 additions & 6 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@
#include "shell.h"
#include "pipe.h"

int status_handler(int status, t_loop_data *loop_data)
{
if (status == WAIT_NEXT_COMMAND)
{
loop_cleanup(loop_data->trimmed_input, loop_data->tokens, \
loop_data->prompt, loop_data->tree);
return (0);
}
return (1);
}

void main_loop(t_minishell_data *data, t_loop_data *loop_data)
{
int status;
Expand All @@ -28,16 +39,16 @@ void main_loop(t_minishell_data *data, t_loop_data *loop_data)
// input_error_checks(loop_data->trimmed_input);
loop_data->tokens = tokenise(loop_data->trimmed_input);
loop_data->tree = parse_tokens(&loop_data->tokens);
print_ast_root(loop_data->tree);
status = execute_ast(loop_data->tree, data);
if (status == WAIT_NEXT_COMMAND)
if (status_handler(status, loop_data))
{
handle_temp_fd(data);
loop_cleanup(loop_data->trimmed_input, loop_data->tokens, \
loop_data->prompt, loop_data->tree);
continue ;
}
handle_temp_fd(data);
loop_cleanup(loop_data->trimmed_input, loop_data->tokens, \
loop_data->prompt, loop_data->tree);
}


}
}

Expand Down
2 changes: 0 additions & 2 deletions src/pipe/pipe.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
#include <sys/wait.h>
#include "pipe.h"

int ft_perror(char *str);
int builtin_pipe(t_ast *node, t_minishell_data *data);
void close_fds(int fds[2]);
pid_t execute_child(t_ast *node, t_minishell_data *data, \
int fd[2], int direction);

Expand Down

0 comments on commit 88024db

Please sign in to comment.