aboutsummaryrefslogtreecommitdiff
path: root/std.py
diff options
context:
space:
mode:
Diffstat (limited to 'std.py')
-rw-r--r--std.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/std.py b/std.py
index 1bb20d4..30d81c9 100644
--- a/std.py
+++ b/std.py
@@ -124,7 +124,19 @@ def std_literal_to_string(arg):
# shell
def std_shell(arg):
assert isinstance(arg, NebString)
- subprocess.run(arg.value)
+ lst = arg.value.split(" ")
+ subprocess.run(lst)
+ return NebBool(True)
+
+def std_shell_pipe(args):
+ prev = None
+ stdout = subprocess.PIPE
+ for idx, arg in enumerate(args.items):
+ if idx == len(args.items) - 1:
+ stdout = None
+ lst = arg.value.split(" ")
+ ret = subprocess.run(lst, stdout=stdout, input=prev)
+ prev = ret.stdout
return NebBool(True)
def evaluate_expression(expr):
@@ -229,5 +241,7 @@ def build_std():
# shell
shell_string = FuncImpl(NebFunction("$", [NebString], NebBool), std_shell)
STD["$"] = [shell_string]
+ shell_pipe = FuncImpl(NebFunction("$|", [NebList], NebBool), std_shell_pipe)
+ STD["$|"] = [shell_pipe]
build_std()