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