Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 12 additions & 14 deletions src/invoke_cmd/invoke_command.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
/* ::: :::::::: */
/* invoke_command.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ttsubo <ttsubo@student.42.fr> +#+ +:+ +#+ */
/* By: dayano <dayano@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/04/20 21:19:33 by dayano #+# #+# */
/* Updated: 2025/05/09 11:43:50 by ttsubo ### ########.fr */
/* Updated: 2025/05/09 16:14:34 by dayano ### ########.fr */
/* */
/* ************************************************************************** */

Expand All @@ -26,13 +26,14 @@ static bool is_unit_builtin(t_cmd *cmd_head)
t_cmd *cmd;

cmd = cmd_head;
if (is_redirect(cmd))
cmd = cmd->next;
if ((is_builtin(cmd) && cmd->next == NULL) || (is_builtin(cmd)
&& is_redirect(cmd->next)))
return (true);
else
if (cmd == NULL)
return (false);
if (!is_builtin(cmd))
return (false);
cmd = cmd->next;
while (cmd != NULL && is_redirect(cmd))
cmd = cmd->next;
return (cmd == NULL);
}

int execute_builtin(t_cmd *cmd, t_minish *minish)
Expand Down Expand Up @@ -69,18 +70,15 @@ int exec_unit_builtin(t_cmd *cmd, t_minish *minish)

redir_result = true;
builtin_cmd = cmd;
if (cmd && is_redirect(cmd))
if (cmd && cmd->next && is_redirect(cmd->next))
{
redir_result = redirect(cmd);
redir_result = redirect(cmd->next);
if (redir_result && cmd->next)
{
cmd = cmd->next;
builtin_cmd = cmd;
}
else
return (print_error(cmd->argv[0]), EXIT_FAILURE);
}
if (cmd->next && is_redirect(cmd->next))
if (cmd && cmd->next && is_redirect(cmd->next))
redir_result = redirect(cmd->next);
if (!redir_result)
return (EXIT_FAILURE);
Expand Down