mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
connec_cmd_execute: handle && and ||
This commit is contained in:
parent
8feacccb15
commit
df73b3d0c7
4 changed files with 61 additions and 1 deletions
36
src/executing/connec_cmd/connec_cmd_execute.c
Normal file
36
src/executing/connec_cmd/connec_cmd_execute.c
Normal 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);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue