Browse Source

fix: operators

master
narnaud 3 years ago
parent
commit
7885c3ee09
  1. 19
      caller.c
  2. 4
      minishell.h

19
caller.c

@ -6,7 +6,7 @@
/* By: mea <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/05/03 11:48:16 by narnaud #+# #+# */
/* Updated: 2022/05/11 01:24:29 by narnaud@stude ### ########.fr */
/* Updated: 2022/05/11 15:29:42 by narnaud@stude ### ########.fr */
/* */
/* ************************************************************************** */
@ -52,12 +52,19 @@ int builtin_call(t_datas *datas, t_command *cmd)
return (-1);
}
int check_skip(t_datas *datas, t_command *cmd)
{
if (cmd->next && ((cmd->ope == AND && !datas->exit_code) \
|| (cmd->ope == OR && datas->exit_code)))
return (0);
return (1);
}
int piper(t_datas *datas, t_command *cmd)
{
int pip[2];
pid_t pid;
int status;
int exit_code;
if (cmd->ope == PIPE)
{
@ -79,11 +86,11 @@ int piper(t_datas *datas, t_command *cmd)
else
{
waitpid(pid, &status, 0);
exit_code = handle_status(datas, status);
if (cmd->next && ((cmd->ope == AND && !exit_code) \
|| (cmd->ope == OR && exit_code)))
datas->exit_code = handle_status(datas, status);
while (cmd->next && check_skip(datas, cmd))
cmd = cmd->next;
if (cmd->next)
piper(datas, cmd->next);
datas->exit_code = exit_code;
}
return (1);
}

4
minishell.h

@ -6,7 +6,7 @@
/* By: mea <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/05/02 13:50:44 by narnaud #+# #+# */
/* Updated: 2022/05/11 01:24:53 by narnaud@stude ### ########.fr */
/* Updated: 2022/05/11 15:19:11 by narnaud@stude ### ########.fr */
/* */
/* ************************************************************************** */
@ -15,7 +15,7 @@
# define ENVP_MAX_SIZE 1024
# define STR_MAX_SIZE 1024
# define PATHS_MAX_SIZE 126
# define DEBUG 1
# define DEBUG 0
# include "libft/libft.h"
# include <fcntl.h>

Loading…
Cancel
Save