diff --git a/src/builtins/ft_export.c b/src/builtins/ft_export.c index e4a1851..05c59ab 100644 --- a/src/builtins/ft_export.c +++ b/src/builtins/ft_export.c @@ -6,7 +6,7 @@ /* By: mmoussou argv + 1, env_t, cmd->outfile); + ft_export(cmd->argv + 1, env_t, STDOUT_FILENO); if (i == 3) ft_unset(&(cmd->argv)[1], env_t); if (i == 7) diff --git a/src/exec/exec_split_cmd.c b/src/exec/exec_split_cmd.c index a7619c3..fc8d952 100644 --- a/src/exec/exec_split_cmd.c +++ b/src/exec/exec_split_cmd.c @@ -6,7 +6,7 @@ /* By: mmoussou cmd, input)) { + if (exec.status == -1) + get_exit_code(127); if (exec.status == -1) printf("minishell : command not found: %s\n", input); free(input); - return (get_exit_code(127)); + return (-1); } free(input); fork_pid = fork(); @@ -64,10 +66,12 @@ int exec_single_cmd(t_cmd *cmd, char **env, t_env *env_t, int pipe_fd[2]) exec.status = switch_cmd_path(cmd, env_t); if (exec.status == -1 || !input || check_file(cmd->cmd, input)) { + if (exec.status == -1) + get_exit_code(127); if (exec.status == -1) printf("minishell : command not found: %s\n", input); free(input); - return (get_exit_code(127)); + return (-1); } free(input); exec.status = exec_single_cmd_execution(cmd, env, env_t, exec); diff --git a/src/exec/utils_exec.c b/src/exec/utils_exec.c index 416892e..10aeb89 100644 --- a/src/exec/utils_exec.c +++ b/src/exec/utils_exec.c @@ -6,7 +6,7 @@ /* By: mmoussou cmd)) + if (is_in_builtins(cmd->cmd) || !cmd->cmd || !cmd->cmd[0]) return (0); if (cmd->cmd[0] == '.' && cmd->cmd[1] == '/') cmd->cmd = get_cmd_local_path(cmd->cmd, env); @@ -100,16 +100,23 @@ int check_file(char *cmd, char *input) if (is_in_builtins(cmd)) return (0); status = stat(cmd, &entry); - if (status) + if (status || !cmd || !*cmd) { + get_exit_code(127); printf("minishell : command not found: %s\n", input); return (1); } if (!S_ISDIR(entry.st_mode) && !access(cmd, X_OK)) return (0); if (S_ISDIR(entry.st_mode)) + { + get_exit_code(126); printf("minishell : %s is a directory.\n", input); + } else + { + get_exit_code(127); printf("minishell : command not found: %s\n", input); + } return (1); }