ambigous redirect stops execution

This commit is contained in:
2024-04-28 14:54:32 +02:00
parent 97d5c24662
commit bb0a62342e
3 changed files with 5 additions and 71 deletions

View File

@ -1,66 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* debug.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/18 15:46:50 by tomoron #+# #+# */
/* Updated: 2024/04/18 20:48:51 by marde-vr ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
void print_parsed_token(t_token *token)
{
while (token)
{
printf("[ARG : \"%s\"]", token->value);
token = token->next;
}
printf("\n");
}
void print_cmd_type(t_cmd_type type, char *value)
{
if (type == CMD)
printf("[CMD : %s] ", value);
if (type == PAREN)
printf("[PAREN : %s] ", value);
if (type == AND)
printf("[AND] ");
if (type == OR)
printf("[OR] ");
if (type == PIPE)
printf("[PIPE] ");
if (type == RED_O_APP)
printf("[RED_O_APP : %s] ", value);
if (type == RED_O)
printf("[RED_O : %s] ", value);
if (type == RED_I)
printf("[RED_I : %s] ", value);
if (type == HERE_DOC)
printf("[HERE_DOC : %s] ", value);
}
void print_parsed_cmd(t_cmd *cmd)
{
while (cmd)
{
print_cmd_type(cmd->cmd_type, cmd->value);
cmd = cmd->next;
}
printf("\n");
}
void print_msh_struct(t_msh *msh)
{
printf("in_fd : %d\n", msh->in_fd);
printf("out_fd : %d\n", msh->out_fd);
printf("in_type: ");
print_cmd_type(msh->in_type, 0);
printf("\nout_type: ");
print_cmd_type(msh->out_type, 0);
printf("\n");
}

View File

@ -6,7 +6,7 @@
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/05 18:15:27 by marde-vr #+# #+# */
/* Updated: 2024/04/26 13:25:15 by marde-vr ### ########.fr */
/* Updated: 2024/04/28 14:52:19 by tomoron ### ########.fr */
/* */
/* ************************************************************************** */
@ -36,7 +36,7 @@ void redirect_input(t_msh *msh, int i, char **cmd_args)
void ambiguous_redirect(char *str, t_msh *msh)
{
ft_printf_fd(2, "minishell: %s: ambiguous redirect\n", str);
msh->in_fd = -1;
msh->in_fd = -2;
g_return_code = 1;
}
@ -66,7 +66,7 @@ int open_input_file(t_msh *msh, t_cmd **cur_token)
}
free_token(filename);
}
return (msh->in_fd == -1);
return (msh->in_fd == -2);
}
int get_in_type(t_msh *msh, t_cmd *t_strt, t_cmd *tokens, int here_doc)

View File

@ -6,7 +6,7 @@
/* By: tomoron <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/19 14:09:44 by tomoron #+# #+# */
/* Updated: 2024/04/25 18:39:52 by tomoron ### ########.fr */
/* Updated: 2024/04/28 14:52:53 by tomoron ### ########.fr */
/* */
/* ************************************************************************** */
@ -91,5 +91,5 @@ int get_out_type(t_msh *msh, t_cmd *cur_cmd)
}
else if (cur_cmd && cur_cmd->cmd_type == PIPE)
msh->out_type = PIPE;
return (ret || msh->in_fd == -1);
return (ret || msh->in_fd == -2);
}