connec_cmd_execute: handle && and ||

This commit is contained in:
Khaïs COLIN 2025-04-07 10:40:31 +02:00
parent 8feacccb15
commit df73b3d0c7
Signed by: logistic-bot
SSH key fingerprint: SHA256:RlpiqKeXpcPFZZ4y9Ou4xi2M8OhRJovIwDlbCaMsuAo
4 changed files with 61 additions and 1 deletions

View file

@ -0,0 +1,36 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* connec_cmd_execute.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/04/07 10:38:55 by khais #+# #+# */
/* Updated: 2025/04/07 10:51:19 by khais ### ########.fr */
/* */
/* ************************************************************************** */
#include "connec_cmd_execute.h"
#include "../cmd/cmd_execute.h"
static void connec_and_cmd_execute(t_connec_cmd *cmd, t_minishell *app)
{
cmd_execute(cmd->first, app);
if (app->last_return_value == 0)
cmd_execute(cmd->second, app);
}
static void connec_or_cmd_execute(t_connec_cmd *cmd, t_minishell *app)
{
cmd_execute(cmd->first, app);
if (app->last_return_value != 0)
cmd_execute(cmd->second, app);
}
void connec_cmd_execute(t_connec_cmd *cmd, t_minishell *app)
{
if (cmd->connector == FT_AND)
connec_and_cmd_execute(cmd, app);
if (cmd->connector == FT_OR)
connec_or_cmd_execute(cmd, app);
}