blob: df28fe880fc2c0e5282e3d67b94b32cad68ab597 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
// This source code is released into the public domain.
export module nihil.posix:execvp;
import nihil.std;
import nihil.core;
import :argv;
import :execv;
import :find_in_path;
import :open_in_path;
namespace nihil {
// execvp: equivalent to execv, except the command will be searched for in $PATH.
export [[nodiscard]] auto
execvp(std::filesystem::path const &file, argv &&args) -> std::expected<execv, error>
{
if constexpr (features::fexecve)
co_return execv(co_await open_in_path(file), std::move(args));
else
co_return execv(co_await find_in_path(file), std::move(args));
}
} // namespace nihil
|