From 36427c0966faa7aecd586b397ed9b845f18172f5 Mon Sep 17 00:00:00 2001 From: Lexi Winter Date: Mon, 30 Jun 2025 09:10:16 +0100 Subject: more refactoring; add stat() --- nihil.posix/execvp.ccm | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'nihil.posix/execvp.ccm') diff --git a/nihil.posix/execvp.ccm b/nihil.posix/execvp.ccm index 680a13e..270e311 100644 --- a/nihil.posix/execvp.ccm +++ b/nihil.posix/execvp.ccm @@ -1,6 +1,7 @@ // This source code is released into the public domain. module; +#include #include #include #include @@ -8,6 +9,7 @@ module; export module nihil.posix:execvp; import nihil.error; +import nihil.monad; import :argv; import :execv; import :find_in_path; @@ -20,11 +22,8 @@ namespace nihil { 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)); + auto filename = co_await find_in_path(file); + co_return execv(std::move(filename), std::move(argv)); } } // namespace nihil -- cgit v1.2.3