summaryrefslogtreecommitdiffstats
path: root/src/e_line.c
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-08-14 20:50:57 +0200
committerJozanLeClerc <bousset.rudy@gmail.com>2020-08-14 20:50:57 +0200
commita2dc5174eb19caebf074b446dae129d17485e7bb (patch)
tree7fcf83e441d10ed9ef60db10de819b1c927dc263 /src/e_line.c
parentJust a few more line and we're good (diff)
download42-minishell-a2dc5174eb19caebf074b446dae129d17485e7bb.tar.gz
42-minishell-a2dc5174eb19caebf074b446dae129d17485e7bb.tar.bz2
42-minishell-a2dc5174eb19caebf074b446dae129d17485e7bb.tar.xz
42-minishell-a2dc5174eb19caebf074b446dae129d17485e7bb.tar.zst
42-minishell-a2dc5174eb19caebf074b446dae129d17485e7bb.zip
&& and || works pretty bav
Diffstat (limited to 'src/e_line.c')
-rw-r--r--src/e_line.c37
1 files changed, 27 insertions, 10 deletions
diff --git a/src/e_line.c b/src/e_line.c
index 4489926..e584140 100644
--- a/src/e_line.c
+++ b/src/e_line.c
@@ -18,6 +18,7 @@
#include "e_externs.h"
#include "e_pipes.h"
#include "s_lpipes.h"
+#include "s_com.h"
#include "s_struct.h"
static uint8_t
@@ -35,27 +36,43 @@ static uint8_t
return (i);
}
+static void
+ e_line_destroy(t_line *ptr)
+{
+ if (ptr->pipes != NULL)
+ {
+ lpipes_clear(&ptr->pipes);
+ }
+}
+
void
e_line(t_msh *msh)
{
t_line *ptr;
uint8_t bu_id;
+ uint8_t previf;
+ previf = 0;
ptr = msh->curr;
while (ptr != NULL)
{
- if (ptr->pipes)
- {
- e_pipes(ptr, msh);
- }
- else if (ptr->com)
+ if ((previf == 0) || (previf == 1 && msh->ret == 0) ||
+ (previf == 2 && msh->ret != 0))
{
- if ((bu_id = get_builtin_id(ptr->com->bin, msh))
- < FT_BUILTINS_COUNT)
- e_builtin(ptr->com, bu_id, msh);
- else
- e_extern(ptr->com, msh);
+ if (ptr->pipes)
+ e_pipes(ptr, msh);
+ else if (ptr->com)
+ {
+ if ((bu_id = get_builtin_id(ptr->com->bin, msh))
+ < FT_BUILTINS_COUNT)
+ e_builtin(ptr->com, bu_id, msh);
+ else
+ e_extern(ptr->com, msh);
+ }
}
+ else
+ e_line_destroy(ptr);
+ previf = ptr->nextif;
ptr = ptr->next;
}
}