Browse Source

a fix

master
narnaud 3 years ago
parent
commit
99e25705e8
  1. 7
      caller.c
  2. 13
      parser.c

7
caller.c

@ -6,7 +6,7 @@
/* By: mea <mea@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/05/03 11:48:16 by narnaud #+# #+# */
/* Updated: 2022/05/17 15:45:59 by mea ### ########.fr */
/* Updated: 2022/05/17 16:28:32 by narnaud ### ########.fr */
/* */
/* ************************************************************************** */
@ -117,9 +117,10 @@ int caller(t_datas *datas, t_command *cmd)
close(cmd->fd[1]);
if (cmd->ope == PIPE)
caller(datas, cmd->next);
else
waitpid(cmd->pid, &status, 0);
if (cmd->ope != PIPE)
{
if (!is_builtin(cmd->argv[0]) && waitpid(cmd->pid, &status, 0))
if (!is_builtin(cmd->argv[0]))
datas->exit_code = handle_status(datas, status);
while (cmd->next && !((cmd->ope == AND && !datas->exit_code) \
|| (cmd->ope == OR && datas->exit_code)))

13
parser.c

@ -6,7 +6,7 @@
/* By: mea <mea@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/05/02 16:09:25 by narnaud #+# #+# */
/* Updated: 2022/05/17 15:52:40 by mea ### ########.fr */
/* Updated: 2022/05/17 16:35:56 by narnaud ### ########.fr */
/* */
/* ************************************************************************** */
@ -18,11 +18,9 @@ static t_token *parse_cmd(t_datas *datas, t_token *tok, t_command *cmd);
t_command *parser(t_datas *datas, t_token *tok, t_command *prev)
{
t_command *cmd;
int syntax_err;
int lex_succ;
syntax_err = 0;
if (!tok)
syntax_err = 1;
lex_succ = ((tok && 1) || 0);
cmd = ft_calloc(1, sizeof(*cmd));
if (prev)
cmd->prev = prev;
@ -38,8 +36,11 @@ t_command *parser(t_datas *datas, t_token *tok, t_command *prev)
free(tok->value);
free(tok);
}
if (free_cmd(cmd), syntax_err)
if (!lex_succ)
{
free_cmd(cmd);
return (NULL);
}
return (cmd);
}

Loading…
Cancel
Save