Fallback to basic path on platforms where _CS_PATH is not defined

This happens on termux for example.
This commit is contained in:
Maxime Coste 2021-10-24 09:37:59 +11:00
parent 7c6f111d5f
commit 502e3f6857

View File

@ -53,9 +53,13 @@ ShellManager::ShellManager(ConstArrayView<EnvVarDesc> builtin_env_vars)
}
else // Get a guaranteed to be POSIX shell binary
{
#if defined(_CS_PATH)
auto size = confstr(_CS_PATH, nullptr, 0);
String path; path.resize(size-1, 0);
confstr(_CS_PATH, path.data(), size);
#else
StringView path = "/bin:/usr/bin";
#endif
for (auto dir : StringView{path} | split<StringView>(':'))
{
auto candidate = format("{}/sh", dir);