Skip to content

Commit

Permalink
fix(main) parentheses
Browse files Browse the repository at this point in the history
  • Loading branch information
neo-jgrec committed May 14, 2023
1 parent 7b969b5 commit 06d84d6
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/execution/exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ void my_parsing(exec_t *exec, char **args, term_t *term)
}
}

int execute_commands(char **args, term_t *term)
int execute_commands(char **args, term_t *term, int input_fd, int output_fd)
{
exec_t exec = {0, 1, 0, 0, 0};
exec_t exec = {input_fd, output_fd, 0, 0, 0};

my_parsing(&exec, args, term);
if (args[exec.cmd_start] != NULL)
Expand Down
4 changes: 2 additions & 2 deletions src/history/execution/exec_history_command.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include <string.h>
#include "my.h"
int execute_commands(char **args, term_t *term);
int execute_commands(char **args, term_t *term, int input, int output);

bool is_existant_event(char *str, history_list_t *list)
{
Expand Down Expand Up @@ -59,6 +59,6 @@ int exec_history_command(char **args, history_list_t *list, term_t *term)
command_is_in_history(list->tail->command, list);
if (list->size > 100)
rm_history_node(list->head, list);
exit_status = execute_commands(new_cmd, term);
exit_status = execute_commands(new_cmd, term, 0, 1);
return (exit_status);
}
4 changes: 2 additions & 2 deletions src/minishell.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

char *clean_str_minishell(char *str, const char *to_clean);
char *replace_alias(char *str, linked_list_t *alias);
int execute_commands(char **args, term_t *term);
int execute_commands(char **args, term_t *term, int input, int output);
int parsing_error(char **args, term_t *term);
char *read_stdin(term_t *term);
char **check_str(char *str, term_t *term);
Expand Down Expand Up @@ -92,6 +92,6 @@ int minishell(char **env)
continue;
if (edit_args_env(term.argv, term.env) == NULL) continue;
signal(SIGINT, handle_sigint_program);
execute_commands(term.argv, &term);
execute_commands(term.argv, &term, 0, 1);
}
}
6 changes: 3 additions & 3 deletions src/parenthese/my_parenthesis.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "my.h"
#include <sys/wait.h>

int execute_commands(char **args, term_t *term);
int execute_commands(char **args, term_t *term, int input, int output);

char **extract_commands_in_parentheses(char **args, int *i)
{
Expand Down Expand Up @@ -47,10 +47,10 @@ void my_parenthesis(UNUSED exec_t *exec, int *i, term_t *term, char **args)
if ((pid = fork()) < 0) {
perror_exit("fork");
} else if (pid == 0) {
execute_commands(subshell_args, term);
execute_commands(subshell_args, term, STDIN_FILENO, STDOUT_FILENO);
exit(0);
} else
waitpid(pid, &status, 0);
exec->cmd_start = (!strcmp(args[*i + 1], ")")) ? *i + 2 : *i + 1;
exec->cmd_start = *i + 1;
free(subshell_args);
}

0 comments on commit 06d84d6

Please sign in to comment.