From 034cd404a129103a8dd7747e6bd00ffd5550da93 Mon Sep 17 00:00:00 2001 From: Lexi Winter Date: Mon, 30 Jun 2025 07:51:23 +0100 Subject: refactoring --- nihil.posix/execl.ccm | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 nihil.posix/execl.ccm (limited to 'nihil.posix/execl.ccm') 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 +#include + +#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 -- cgit v1.2.3