Browse Source

fix: halt calls, new: debug define

master
narnaud 3 years ago
parent
commit
d3deaaebf0
  1. 6
      built-in.c
  2. 10
      caller.c
  3. 3
      minishell.h

6
built-in.c

@ -6,7 +6,7 @@
/* By: narnaud <narnaud@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/01/06 09:02:57 by narnaud #+# #+# */
/* Updated: 2022/05/07 23:17:15 by narnaud@stude ### ########.fr */
/* Updated: 2022/05/11 01:27:56 by narnaud@stude ### ########.fr */
/* */
/* ************************************************************************** */
@ -78,8 +78,8 @@ int ft_cd(t_command *cmd)
int ft_exit(t_datas *datas, t_command *cmd)
{
if (cmd->argc > 1)
halt(datas, EXIT_SUCCESS);
halt(datas, EXIT_SUCCESS, 0);
else
halt(datas, ft_atoi(cmd->argv[1]));
halt(datas, ft_atoi(cmd->argv[1]), 0);
return (1);
}

10
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:15:39 by narnaud@stude ### ########.fr */
/* Updated: 2022/05/11 01:24:29 by narnaud@stude ### ########.fr */
/* */
/* ************************************************************************** */
@ -72,18 +72,18 @@ int piper(t_datas *datas, t_command *cmd)
close(cmd->fd[1]);
if (cmd->fd[0])
close(cmd->fd[0]);
printf("%s -ope: %d, pid: %d, fdin: %d, fdout: %d\n", cmd->argv[0], cmd->ope, pid, cmd->fd[0], cmd->fd[1]);
if (DEBUG)
printf("%s -ope: %d, pid: %d, fdin: %d, fdout: %d\n", cmd->argv[0], cmd->ope, pid, cmd->fd[0], cmd->fd[1]);
if (cmd->ope == PIPE)
pid = piper(datas, cmd->next);
else
{
waitpid(pid, &status, 0);
exit_code = handle_status(datas, status);
if (!cmd->next)
datas->exit_code = exit_code;
else if (cmd->next && ((cmd->ope == AND && !exit_code) \
if (cmd->next && ((cmd->ope == AND && !exit_code) \
|| (cmd->ope == OR && exit_code)))
piper(datas, cmd->next);
datas->exit_code = exit_code;
}
return (1);
}

3
minishell.h

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

Loading…
Cancel
Save