diff options
Diffstat (limited to 'src/m_loop.c')
-rw-r--r-- | src/m_loop.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/m_loop.c b/src/m_loop.c index 6ec2a3b..1641d53 100644 --- a/src/m_loop.c +++ b/src/m_loop.c @@ -37,12 +37,15 @@ #include "u_utils.h" #include "u_parse.h" #include "u_vars.h" +#include "u_vars_next.h" static void m_parse_and_run_line(char line[], unsigned char previf, t_msh *msh) { t_line_block *ptr; + size_t i; + t_bool pipe; p_line(line, msh); ptr = msh->curr; @@ -51,14 +54,24 @@ static void m_parse_and_run_line(char line[], if ((previf == 0) || (previf == 1 && msh->ret == 0) || (previf == 2 && msh->ret != 0)) { - if ((p_find_good_pipe(ptr->lblock) == TRUE - && (s_split_pipes(ptr->lblock, msh)) == NULL) - || (msh->com = s_com_new(ptr->lblock, msh)) == NULL) + pipe = p_find_good_pipe(ptr->lblock); + if ((pipe == TRUE && s_split_pipes(ptr->lblock, msh) == NULL) + || (msh->com = s_com_new(ptr->lblock, msh)) == NULL) { previf = ptr->nextif; ptr = ptr->next; continue ; } + if (msh->com != NULL && pipe == FALSE) + { + i = 0; + while (msh->com->argv != NULL && msh->com->argv[i] != NULL) + i++; + if (msh->com->argv != NULL && msh->com->argv[0] != NULL) + u_subst_var_value("$_", msh->com->argv[i - 1], msh); + else + u_subst_var_value("$_", msh->com->bin, msh); + } e_line_block(msh); s_com_destroy(&msh->com); s_lpipes_clear(&msh->pipes); |