From 928f3250b3914c88d105d8cf297c6b27a96ed5ad Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Mon, 24 Feb 2025 18:23:18 -0500 Subject: Add $Shell:execute() --- stdlib/shell.c | 6 ++++++ stdlib/shell.h | 1 + 2 files changed, 7 insertions(+) (limited to 'stdlib') diff --git a/stdlib/shell.c b/stdlib/shell.c index 593301a2..08898acc 100644 --- a/stdlib/shell.c +++ b/stdlib/shell.c @@ -75,6 +75,12 @@ public OptionalText_t Shell$run(Shell_t command) return Text$from_bytes(bytes); } +public int32_t Shell$execute(Shell_t command) +{ + const char *cmd_str = Text$as_c_string(command); + return system(cmd_str); +} + static void _line_reader_cleanup(FILE **f) { if (f && *f) { diff --git a/stdlib/shell.h b/stdlib/shell.h index 9b4e77df..a8f35f65 100644 --- a/stdlib/shell.h +++ b/stdlib/shell.h @@ -21,6 +21,7 @@ Shell_t Shell$escape_text(Text_t text); Shell_t Shell$escape_text_array(Array_t texts); OptionalArray_t Shell$run_bytes(Shell_t command); OptionalText_t Shell$run(Shell_t command); +int32_t Shell$execute(Shell_t command); #define Shell$hash Text$hash #define Shell$compare Text$compare -- cgit v1.2.3