diff options
Diffstat (limited to 'nihil.posix/execl.ccm')
| -rw-r--r-- | nihil.posix/execl.ccm | 40 |
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 |
