diff --git a/Makefile b/Makefile index a935082..ad27236 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ # By: mmoussou cmd)) + return (0); if (cmd->cmd[0] == '.' && cmd->cmd[1] == '/') cmd->cmd = get_cmd_local_path(cmd->cmd, env); else if (cmd->cmd[0] != '/') @@ -46,7 +92,7 @@ int exec_single_cmd(t_cmd *cmd, char **env, t_env *env_t, int pipe_fd[2]) input = ft_strdup(cmd->cmd); status = switch_cmd_path(cmd, env_t); - if (status == -1 || !input || access(cmd->cmd, X_OK)) + if (status == -1 || !input || (access(cmd->cmd, X_OK) && !is_in_builtins(cmd->cmd))) { printf("minishell : command not found: %s\n", input); return (-1); @@ -67,7 +113,7 @@ int exec_single_cmd(t_cmd *cmd, char **env, t_env *env_t, int pipe_fd[2]) if (pipe_fd[0] != -1) close(pipe_fd[1]); if (status != -1) - execve(cmd->cmd, cmd->argv, env); + exec_cmd(cmd->cmd, cmd->argv, env, env_t); exit(-1); } return (fork_pid); @@ -143,9 +189,10 @@ int exec_split_cmd(t_list *list_cmd, t_env *env) i--; if (i < 1) return (0); - while (i) + waitpid(status, &return_code, 0); + while (i - 1) { - waitpid(-1, &return_code, 0); + waitpid(-1, NULL, 0); i--; } print_return_value(return_code); diff --git a/src/exec/format_quotes.c b/src/exec/format_quotes.c new file mode 100644 index 0000000..b92a452 --- /dev/null +++ b/src/exec/format_quotes.c @@ -0,0 +1,156 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* format_quotes.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: mmoussou cmd); + new_cmd = format_quotes_string(cmd->cmd); + if (!new_cmd) + return (-1); + free(cmd->cmd); + cmd->cmd = new_cmd; + printf("after : %s\n", cmd->cmd); + i = 0; + while (cmd->argv[i]) + { + printf("before : %s\n", cmd->argv[i]); + new_cmd = format_quotes_string(cmd->argv[i]); + if (!new_cmd) + return (-1); + free(cmd->argv[i]); + cmd->argv[i] = new_cmd; + printf("after : %s\n", cmd->argv[i]); + i++; + } + return (0); +} + +int format_quotes(t_list *list_cmd) +{ + printf("aled\n"); + if (!list_cmd) + return (0); + while (list_cmd) + { + format_quotes_cmd(list_cmd->content); + list_cmd = list_cmd->next; + } + return (0); +} diff --git a/src/exec/heredoc.c b/src/exec/heredoc.c index 5ce7a14..a77ebab 100644 --- a/src/exec/heredoc.c +++ b/src/exec/heredoc.c @@ -6,7 +6,7 @@ /* By: mmoussou 0) fd = open(path, O_RDONLY); else diff --git a/src/main.c b/src/main.c index e9b242e..17b5ff7 100644 --- a/src/main.c +++ b/src/main.c @@ -6,7 +6,7 @@ /* By: mmoussou content))->redirection)) continue ; cmd_list = get_cmd_list(piped); + format_quotes(cmd_list); exec_split_cmd(cmd_list, &env_l); free(test); ft_lstclear(&piped, free_token);