aboutsummaryrefslogtreecommitdiffstats
path: root/nihil.posix/execshell.ccm
diff options
context:
space:
mode:
authorLexi Winter <lexi@le-fay.org>2025-06-30 07:51:23 +0100
committerLexi Winter <lexi@le-fay.org>2025-06-30 07:51:23 +0100
commit034cd404a129103a8dd7747e6bd00ffd5550da93 (patch)
treed27946517d4d9333abd26ac50bbd4a436093e2ce /nihil.posix/execshell.ccm
parent3e7902f7d790a486d3d9cb978df193f07f3a6ad9 (diff)
downloadnihil-034cd404a129103a8dd7747e6bd00ffd5550da93.tar.gz
nihil-034cd404a129103a8dd7747e6bd00ffd5550da93.tar.bz2
refactoring
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