aboutsummaryrefslogtreecommitdiffstats
path: root/nihil.posix/execshell.ccm
diff options
context:
space:
mode:
Diffstat (limited to 'nihil.posix/execshell.ccm')
-rw-r--r--nihil.posix/execshell.ccm21
1 files changed, 21 insertions, 0 deletions
diff --git a/nihil.posix/execshell.ccm b/nihil.posix/execshell.ccm
new file mode 100644
index 0000000..1fbfccf
--- /dev/null
+++ b/nihil.posix/execshell.ccm
@@ -0,0 +1,21 @@
+// This source code is released into the public domain.
+module;
+
+#include <string>
+
+export module nihil.posix:execshell;
+
+import nihil.error;
+import :execv;
+import :execl;
+
+namespace nihil {
+
+// execshell: a spawn executor which runs the process by invoking /bin/sh -c with the
+// single argument, equivalent to system(3).
+export [[nodiscard]] auto execshell(std::string_view command) -> execv
+{
+ return execl("/bin/sh", "sh", "-c", command);
+}
+
+} // namespace nihil