🔨」 fix: Error when in or out not valid

This commit is contained in:
2024-07-30 19:04:42 +02:00
parent 5c0c4bbbfd
commit 64ab542422
2 changed files with 11 additions and 6 deletions

View File

@ -6,7 +6,7 @@
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/10/30 23:06:24 by mmoussou #+# #+# */
/* Updated: 2024/07/29 19:23:16 by adjoly ### ########.fr */
/* Updated: 2024/07/30 19:04:19 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */

View File

@ -6,7 +6,7 @@
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/05/30 10:48:41 by adjoly #+# #+# */
/* Updated: 2024/07/30 17:17:13 by adjoly ### ########.fr */
/* Updated: 2024/07/30 19:03:54 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
@ -18,6 +18,12 @@
#include <stdio.h>
#include "libft.h"
void parsing_msg(t_cmd *cmd)
{
if (cmd->infile == -1 || cmd->outfile == -1)
send_error_parsing(ERROR_NO_FILE);
}
t_cmd *get_redir_fd(void *content, t_list *tmp)
{
t_redir_sign sign[2];
@ -31,10 +37,9 @@ t_cmd *get_redir_fd(void *content, t_list *tmp)
while (tmp)
{
open_redir((t_redirection *)tmp->content, cmd, sign);
if (cmd->infile >= -1 || cmd->outfile == -1)
if (cmd->infile <= -1 || cmd->outfile == -1)
{
if (cmd->infile == -1 || cmd->outfile == -1)
send_error_parsing(ERROR_NO_FILE);
parsing_msg(cmd);
free(cmd);
return (NULL);
}