fix: dir check after path confirmed
This commit is contained in:
parent
bceabcb382
commit
859b9c181a
@ -36,13 +36,6 @@ void executor_child(t_minishell *msh, t_command *command)
|
|||||||
executor_close_fds(command->n_fds);
|
executor_close_fds(command->n_fds);
|
||||||
path = executor_absolute_path(msh, command->args[0]);
|
path = executor_absolute_path(msh, command->args[0]);
|
||||||
// TODO: If the path variable points to a dir, it exists so the command won't fail (while ofc it should?)
|
// TODO: If the path variable points to a dir, it exists so the command won't fail (while ofc it should?)
|
||||||
if (is_dir(path))
|
|
||||||
{
|
|
||||||
ft_putstr_fd(RED BOLD, 2);
|
|
||||||
ft_putstr_fd("minishell: ", 2);
|
|
||||||
ft_putstr_fd(command->args[0], 2);
|
|
||||||
ft_putstr_fd(": " RESET "is a directory\n", 2);
|
|
||||||
}
|
|
||||||
if (path == NULL || access(path, F_OK | X_OK) != 0)
|
if (path == NULL || access(path, F_OK | X_OK) != 0)
|
||||||
{
|
{
|
||||||
ft_putstr_fd(RED BOLD, 2);
|
ft_putstr_fd(RED BOLD, 2);
|
||||||
@ -50,5 +43,12 @@ void executor_child(t_minishell *msh, t_command *command)
|
|||||||
ft_putstr_fd(": " RESET "command not found\n", 2);
|
ft_putstr_fd(": " RESET "command not found\n", 2);
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
if (is_dir(path))
|
||||||
|
{
|
||||||
|
ft_putstr_fd(RED BOLD, 2);
|
||||||
|
ft_putstr_fd("minishell: ", 2);
|
||||||
|
ft_putstr_fd(command->args[0], 2);
|
||||||
|
ft_putstr_fd(": " RESET "is a directory\n", 2);
|
||||||
|
}
|
||||||
execve(path, command->args, environment_get_arr(msh));
|
execve(path, command->args, environment_get_arr(msh));
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user