args
This commit is contained in:
@@ -82,12 +82,8 @@ int main(int ac, char **av, char **envp)
|
|||||||
{
|
{
|
||||||
while (!input || !input[0])
|
while (!input || !input[0])
|
||||||
input = powerline();
|
input = powerline();
|
||||||
ft_debug("input: %s\n", input);
|
|
||||||
ft_debug("powerline\n");
|
|
||||||
msh->head = parser(input, msh);
|
msh->head = parser(input, msh);
|
||||||
ft_debug("parsed\n");
|
|
||||||
msh->ex_code = execute_command(msh->head);
|
msh->ex_code = execute_command(msh->head);
|
||||||
ft_debug("executed\n");
|
|
||||||
free(input);
|
free(input);
|
||||||
input = NULL;
|
input = NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -115,15 +115,28 @@ void create_redir(t_node *cpy, t_ast_n *self)
|
|||||||
|
|
||||||
t_node *get_cmd(t_node *lst)
|
t_node *get_cmd(t_node *lst)
|
||||||
{
|
{
|
||||||
while (lst)
|
t_node *cpy;
|
||||||
|
|
||||||
|
cpy = lst;
|
||||||
|
while (cpy)
|
||||||
{
|
{
|
||||||
if (get_redir(lst) != _NR && lst->next && lst->next->next && get_redir(lst->next->next) == _NR)
|
if (get_redir(cpy) != _NR && cpy->next && cpy->next->next && get_redir(cpy->next->next) == _NR)
|
||||||
return (lst);
|
return (cpy->next->next);
|
||||||
lst = lst->next;
|
cpy = cpy->next;
|
||||||
}
|
}
|
||||||
return (lst);
|
return (lst);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char **get_args(t_node *cmd)
|
||||||
|
{
|
||||||
|
t_node *cpy;
|
||||||
|
|
||||||
|
cpy = cmd;
|
||||||
|
while (cpy && !get_redir(cpy))
|
||||||
|
cpy = cpy->next;
|
||||||
|
return (lltotab(cmd, cpy));
|
||||||
|
}
|
||||||
|
|
||||||
void create_cmd(t_ast_n *self, t_node *lst)
|
void create_cmd(t_ast_n *self, t_node *lst)
|
||||||
{
|
{
|
||||||
t_node *cpy;
|
t_node *cpy;
|
||||||
@@ -134,8 +147,8 @@ void create_cmd(t_ast_n *self, t_node *lst)
|
|||||||
self->redir = ft_calloc(1, sizeof(t_redir));
|
self->redir = ft_calloc(1, sizeof(t_redir));
|
||||||
self->redir[0] = _NR;
|
self->redir[0] = _NR;
|
||||||
cmd_node = get_cmd(lst);
|
cmd_node = get_cmd(lst);
|
||||||
self->cmd = cmd_node->val;
|
self->cmd = ft_strdup(cmd_node->val);
|
||||||
self->args = ft_split("NOT SET", " ");
|
self->args = get_args(cmd_node);
|
||||||
cpy = lst;
|
cpy = lst;
|
||||||
create_redir(cpy, self);
|
create_redir(cpy, self);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user