mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
redirection parsing: detect malformed redirection
This commit is contained in:
parent
06dd3c3e83
commit
5df876bba3
4 changed files with 26 additions and 8 deletions
|
|
@ -6,7 +6,7 @@
|
|||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/03/07 12:30:04 by khais #+# #+# */
|
||||
/* Updated: 2025/03/10 16:11:46 by khais ### ########.fr */
|
||||
/* Updated: 2025/03/10 16:40:17 by khais ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -15,6 +15,7 @@
|
|||
#include "redirection_list.h"
|
||||
#include <stdlib.h>
|
||||
#include "redirection_type.h"
|
||||
#include "../../ft_errno.h"
|
||||
#include <unistd.h>
|
||||
|
||||
/*
|
||||
|
|
@ -53,6 +54,8 @@ struct s_simple_cmd *parse_redirections(struct s_simple_cmd *cmd)
|
|||
{
|
||||
wordlist_destroy_idx(&cmd->words, i);
|
||||
marker = wordlist_pop_idx(&cmd->words, i);
|
||||
if (marker == NULL)
|
||||
return (ft_errno(FT_EMALFORMED_REDIRECTION), NULL);
|
||||
redirection = redirection_create(type, marker);
|
||||
if (redirection == NULL)
|
||||
return (NULL);
|
||||
|
|
@ -60,8 +63,7 @@ struct s_simple_cmd *parse_redirections(struct s_simple_cmd *cmd)
|
|||
if (cmd->redirections == NULL)
|
||||
return (redirection_destroy(redirection), NULL);
|
||||
}
|
||||
else
|
||||
i++;
|
||||
i++;
|
||||
}
|
||||
return (cmd);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue