aboutsummaryrefslogtreecommitdiffstats
path: root/nihil.posix/execl.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/execl.ccm
parent3e7902f7d790a486d3d9cb978df193f07f3a6ad9 (diff)
downloadnihil-034cd404a129103a8dd7747e6bd00ffd5550da93.tar.gz
nihil-034cd404a129103a8dd7747e6bd00ffd5550da93.tar.bz2
refactoring
Diffstat (limited to 'nihil.posix/execl.ccm')
-rw-r--r--nihil.posix/execl.ccm40
1 files changed, 40 insertions, 0 deletions
diff --git a/nihil.posix/execl.ccm b/nihil.posix/execl.ccm
new file mode 100644
index 0000000..f3cbf9a
--- /dev/null
+++ b/nihil.posix/execl.ccm
@@ -0,0 +1,40 @@
+/*
+ * This source code is released into the public domain.
+ */
+
+module;
+
+#include <expected>
+#include <string>
+
+#include "nihil.hh"
+
+export module nihil.posix:execl;
+
+import nihil.error;
+import :argv;
+import :execv;
+import :fexecv;
+
+namespace nihil {
+
+/*
+ * execl: equivalent to (f)execv, except the arguments are passed as a
+ * variadic pack of string-like objects.
+ */
+
+export [[nodiscard]] auto execl(std::string_view path, auto &&...args) -> execv
+{
+ return execv(path, argv({std::string_view(args)...}));
+}
+
+#ifdef NIHIL_HAVE_FEXECVE
+
+export [[nodiscard]] auto execl(fd &&executable, auto &&...args) -> fexecv
+{
+ return fexecv(std::move(executable), argv({std::string_view(args)...}));
+}
+
+#endif // NIHIL_HAVE_FEXECVE
+
+} // namespace nihil