summaryrefslogtreecommitdiffstats
path: root/src/m_loop.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/m_loop.c')
-rw-r--r--src/m_loop.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/m_loop.c b/src/m_loop.c
index b111577..718b23e 100644
--- a/src/m_loop.c
+++ b/src/m_loop.c
@@ -25,6 +25,7 @@
#include "e_line.h"
#include "m_loop_multis.h"
#include "m_prompt.h"
+#include "p_lblock.h"
#include "p_line.h"
#include "s_com.h"
#include "s_lpipes.h"
@@ -33,26 +34,28 @@
#include "u_parse.h"
#include "u_vars.h"
-static void m_parse_and_run_line(char line[], t_msh *msh)
+static void m_parse_and_run_line(char line[], uint8_t previf, t_msh *msh)
{
t_line_block *ptr;
- uint8_t previf;
p_line(line, msh);
- previf = 0;
ptr = msh->curr;
while (ptr != NULL)
{
if ((previf == 0) || (previf == 1 && msh->ret == 0)
|| (previf == 2 && msh->ret != 0))
{
- if ((msh->com = s_com_new(ptr->lblock, msh)) == NULL)
+ if (p_find_good_pipe(ptr->lblock) == TRUE
+ && (s_split_pipes(ptr->lblock, msh)) == NULL)
+ break ;
+ else if ((msh->com = s_com_new(ptr->lblock, msh)) == NULL)
break ;
e_line(msh);
- s_com_destroy(&msh->com);
+ if (msh->com != NULL)
+ s_com_destroy(&msh->com);
+ if (msh->pipes != NULL)
+ s_lpipes_clear(&msh->pipes);
}
- else if (msh->pipes != NULL)
- s_lpipes_clear(&msh->pipes);
previf = ptr->nextif;
ptr = ptr->next;
}
@@ -141,7 +144,7 @@ uint8_t m_loop(int32_t fd, t_msh *msh)
line = m_check_multis(fd, line, msh);
if (fd == STDIN_FILENO)
m_handle_hist(hist, line, msh);
- m_parse_and_run_line(line, msh);
+ m_parse_and_run_line(line, 0, msh);
}
else
ft_memdel((void*)&line);