redir subsh bug fix
This commit is contained in:
@@ -75,10 +75,12 @@ void create_cmd(t_ast_n *self, t_node *lst)
|
||||
create_redir(lst, self);
|
||||
// debug
|
||||
int i = -1;
|
||||
ft_debug("==== CMD REDIR\n");
|
||||
while (self->files && self->files[++i])
|
||||
ft_debug("redir : [%d]%s\n",self->redir[i], self->files[i]);
|
||||
ft_debug("====\n");
|
||||
ft_debug("redi : [%d]%s\n",self->redir[i], self->files[i]);
|
||||
ft_debug("==== CMD ARGS\n");
|
||||
i = -1;
|
||||
while (self->args && self->args[++i])
|
||||
ft_debug("args : %s\n",self->args[i], self->args[i]);
|
||||
ft_debug("==== CMD DONE\n\n");
|
||||
}
|
||||
|
||||
@@ -46,5 +46,12 @@ void create_subsh(t_ast_n *self, t_node *lst, t_msh *msh)
|
||||
self->redir = ft_calloc(1, sizeof(t_redir));
|
||||
self->redir[0] = _NR;
|
||||
create_redir_subsh(lst, self);
|
||||
// debug
|
||||
int i = -1;
|
||||
ft_debug("==== SUBSH REDIR\n");
|
||||
while (self->redir[++i])
|
||||
ft_debug("subsh_redir : [%d]%s\n", self->redir[i], self->files[i]);
|
||||
ft_debug("==== SUBSH DONE\n\n");
|
||||
|
||||
// free(cutted);
|
||||
}
|
||||
|
||||
@@ -13,6 +13,17 @@
|
||||
#include "../../../includes/minishell.h"
|
||||
|
||||
static int last_tok_subsh(t_node *lst)
|
||||
{
|
||||
while (lst)
|
||||
{
|
||||
if ((lst->next == NULL) && !ft_strncmp(lst->val, ")", 1))
|
||||
return (1);
|
||||
lst = lst->next;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int last_tok_redir(t_node *lst)
|
||||
{
|
||||
while (lst)
|
||||
{
|
||||
@@ -56,7 +67,7 @@ t_node *get_top_token(t_node *lst, t_state *state)
|
||||
*state = _SUBSH;
|
||||
if (!ft_strncmp(lst->val, "(", 1) && last_tok_subsh(lst))
|
||||
return (lst);
|
||||
else if (find_token("&&", lst))
|
||||
if (find_token("&&", lst))
|
||||
{
|
||||
*state = _AND;
|
||||
return (find_token("&&", lst));
|
||||
@@ -71,6 +82,8 @@ t_node *get_top_token(t_node *lst, t_state *state)
|
||||
*state = _PLINE;
|
||||
return (find_token("|", lst));
|
||||
}
|
||||
else if (!ft_strncmp(lst->val, "(", 1) && last_tok_redir(lst))
|
||||
return (lst);
|
||||
else
|
||||
{
|
||||
*state = UNDEF;
|
||||
|
||||
Reference in New Issue
Block a user