mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
redirection parsing: use redir_type_from_worddesc
This commit is contained in:
parent
e7946b4192
commit
2a1660865d
1 changed files with 6 additions and 4 deletions
|
|
@ -6,7 +6,7 @@
|
|||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/03/07 12:30:04 by khais #+# #+# */
|
||||
/* Updated: 2025/03/07 14:53:22 by khais ### ########.fr */
|
||||
/* Updated: 2025/03/07 14:58:22 by khais ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
#include "redirection.h"
|
||||
#include "redirection_list.h"
|
||||
#include <stdlib.h>
|
||||
#include "libft.h"
|
||||
#include "redirection_type.h"
|
||||
|
||||
/*
|
||||
** Modify the given simple_cmd in-place, removing all redirection directives
|
||||
|
|
@ -30,12 +30,14 @@ struct s_simple_cmd *parse_redirections(struct s_simple_cmd *cmd)
|
|||
{
|
||||
t_worddesc *marker;
|
||||
t_redirection *redirection;
|
||||
t_redir_type type;
|
||||
|
||||
if (ft_strcmp(">", cmd->words->word->word) == 0)
|
||||
type = redir_type_from_worddesc(cmd->words->word);
|
||||
if (type == REDIR_OUTPUT)
|
||||
{
|
||||
worddesc_destroy(wordlist_pop(&cmd->words));
|
||||
marker = wordlist_pop(&cmd->words);
|
||||
redirection = redirection_create(REDIR_OUTPUT, marker);
|
||||
redirection = redirection_create(type, marker);
|
||||
if (redirection == NULL)
|
||||
return (NULL);
|
||||
cmd->redirections = redir_list_push(cmd->redirections, redirection);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue