aboutsummaryrefslogtreecommitdiffstats
path: root/nihil.posix/execvp.ccm
diff options
context:
space:
mode:
authorLexi Winter <lexi@le-fay.org>2025-06-30 09:10:16 +0100
committerLexi Winter <lexi@le-fay.org>2025-06-30 09:10:16 +0100
commit36427c0966faa7aecd586b397ed9b845f18172f5 (patch)
tree0d86c7ca9ac9e2e768b54d491bf596fb84f5e45a /nihil.posix/execvp.ccm
parent034cd404a129103a8dd7747e6bd00ffd5550da93 (diff)
downloadnihil-36427c0966faa7aecd586b397ed9b845f18172f5.tar.gz
nihil-36427c0966faa7aecd586b397ed9b845f18172f5.tar.bz2
more refactoring; add stat()
Diffstat (limited to 'nihil.posix/execvp.ccm')
-rw-r--r--nihil.posix/execvp.ccm9
1 files changed, 4 insertions, 5 deletions
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 <coroutine>
#include <string>
#include <expected>
#include <format>
@@ -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<execv, error>
{
- 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