aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author_ov4 <ov4@ov4.org>2026-10-04 18:38:39 +0000
committer_ov4 <ov4@ov4.org>2026-10-04 18:38:39 +0000
commitd97297934dd57e033325abaa2d9e41f389b08f75 (patch)
treeb9c51263fc084df1357b0fd84204f334a1f99409
parentf60cb6c7b365d1a9f18153b1d2fd0cfe5df754e4 (diff)
prepare for pipe
-rw-r--r--include/eval.h17
-rw-r--r--src/eval/eval_err.cc3
-rw-r--r--src/eval/eval_exe.cc5
-rw-r--r--src/eval/eval_tree_cd.cc8
4 files changed, 29 insertions, 4 deletions
diff --git a/include/eval.h b/include/eval.h
index 00f466a..c93d346 100644
--- a/include/eval.h
+++ b/include/eval.h
@@ -5,9 +5,22 @@
namespace ov4
{
+
+struct T_pipe
+{
+ enum class T_pipe_type
+ {
+ NOT_PIPE,
+ WRITE_PIPE,
+ READ_PIPE,
+ };
+ T_pipe_type pipe_type = NOT_PIPE;
+ int fd = -1;
+} T_pipe_not_pipe;
+
int eval_exe(const std::string &s, bool is_async);
-int eval_exe(const std::string &s, bool is_async, const T_lexer *lexer_instance, size_t i);
-int eval_tree_cd(size_t i, const T_lexer &lexer_instance, bool inside_subshell);
+int eval_exe(const std::string &s, bool is_async, const T_lexer *lexer_instance, size_t i, const T_pipe &pi = T_pipe_not_pipe);
+int eval_tree_cd(size_t i, const T_lexer &lexer_instance, bool inside_subshell, T_pipe pi = T_pipe_not_pipe);
void eval(char *cmdline);
void eval_err(int err);
diff --git a/src/eval/eval_err.cc b/src/eval/eval_err.cc
index 3d90262..6a7c4e0 100644
--- a/src/eval/eval_err.cc
+++ b/src/eval/eval_err.cc
@@ -8,6 +8,9 @@ using namespace std;
namespace ov4
{
+/*
+ * print exec error message
+ */
void eval_err(int err)
{
switch (err)
diff --git a/src/eval/eval_exe.cc b/src/eval/eval_exe.cc
index 4e893f3..9a2a592 100644
--- a/src/eval/eval_exe.cc
+++ b/src/eval/eval_exe.cc
@@ -23,7 +23,10 @@ int eval_exe(const string &s, bool is_async)
return eval_exe(s, is_async, nullptr, string::npos);
}
-int eval_exe(const string &s, bool is_async, const T_lexer *lexer_instance, size_t i)
+/*
+ * receive a single command, and execute
+ */
+int eval_exe(const string &s, bool is_async, const T_lexer *lexer_instance, size_t i, const T_pipe &pi)
{
loggerln("eval_exe: receive {}", s);
diff --git a/src/eval/eval_tree_cd.cc b/src/eval/eval_tree_cd.cc
index 7d7c1af..0e5b8f4 100644
--- a/src/eval/eval_tree_cd.cc
+++ b/src/eval/eval_tree_cd.cc
@@ -1,6 +1,7 @@
#include "eval.h"
#include <string>
+#include <unistd.h>
#include "error.h"
#include "lang_analysis/lexer_class.h"
@@ -15,11 +16,16 @@ using namespace std;
namespace ov4
{
-int eval_tree_cd(size_t i, const T_lexer &lexer_instance, bool inside_subshell)
+/*
+ * browse AST
+ * and recurse or set up a subshell
+ */
+int eval_tree_cd(size_t i, const T_lexer &lexer_instance, bool inside_subshell, T_pipe pi)
{
// TODO: async
int ret = -1;
+ int fd[2];
println("eval_tree_cd: processing {} subshell {}", i, (lexer_instance.ast[i].subshell ? "TRUE" : "FALSE"));