// This source code is released into the public domain. module; #include #include #include export module nihil.posix:execvp; import nihil.error; import :argv; import :execv; import :find_in_path; namespace nihil { // execvp: equivalent to execv, except the command is passed as // a filename instead of a file descriptor. If the filename is not // an absolute path, it will be searched for in $PATH. export [[nodiscard]] auto execvp(std::string_view file, argv &&argv) -> std::expected { auto filename = nihil::find_in_path(file); if (!filename) return std::unexpected(nihil::error( std::format("executable not found in path: {}", file))); return execv(std::move(*filename), std::move(argv)); } } // namespace nihil