Consider `SHELL` env var (#3997)

This commit is contained in:
Hind-M 2025-06-30 15:21:17 +02:00 committed by GitHub
parent b3d580e610
commit e39196dc20
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 20 additions and 0 deletions

View File

@ -97,6 +97,14 @@ namespace mamba
{ {
return "fish"; return "fish";
} }
// Get `SHELL` environment variable if set
// Standard values are assumed to be `/bin/{shell_type}` or `/usr/bin/{shell_type}`
if (util::get_env("SHELL").has_value())
{
return util::split(util::get_env("SHELL").value(), "/").back();
}
return ""; return "";
} }

View File

@ -460,6 +460,10 @@ namespace
std::vector<std::string> v21 = { "conda-forge/linux64:", "xtensor==0.12.3" }; std::vector<std::string> v21 = { "conda-forge/linux64:", "xtensor==0.12.3" };
REQUIRE(rsplit("conda-forge/linux64::xtensor==0.12.3", ":", 1) == v21); REQUIRE(rsplit("conda-forge/linux64::xtensor==0.12.3", ":", 1) == v21);
std::vector<std::string> es3 = { "" };
REQUIRE(split(es3[0], ".") == es3);
REQUIRE(rsplit(es3[0], ".") == es3);
} }
TEST_CASE("join") TEST_CASE("join")

View File

@ -225,6 +225,14 @@ def test_init(tmp_home, tmp_root_prefix, shell_type, prefix_selector, multiple_t
assert (tmp_root_prefix / "condabin").is_dir() assert (tmp_root_prefix / "condabin").is_dir()
def test_shell_init_with_env_var(tmp_home, tmp_root_prefix):
skip_if_shell_incompat("bash")
umamba_cmd = helpers.get_umamba()
res = helpers.umamba_run("sh", "-c", f"export SHELL=/bin/bash; {umamba_cmd} shell init")
assert res
assert (tmp_root_prefix / "etc" / "profile.d").is_dir()
def test_dash(tmp_home, tmp_root_prefix): def test_dash(tmp_home, tmp_root_prefix):
skip_if_shell_incompat("dash") skip_if_shell_incompat("dash")
umamba = helpers.get_umamba() umamba = helpers.get_umamba()