diff options
| author | xq114 <[email protected]> | 2021-08-24 19:57:35 +0800 |
|---|---|---|
| committer | xq114 <[email protected]> | 2021-08-24 19:57:35 +0800 |
| commit | a21ec09a71f0e4c60957b37eb61e33f1a4ae6e86 (patch) | |
| tree | ed1bcc557207e8b9bafc3622aad07e26c5e16ab9 /xmake/modules | |
| parent | a1e286a66cf7e9df8ec1cad9316386d7f2a75b33 (diff) | |
improve virtualenv on linux
Diffstat (limited to 'xmake/modules')
| -rw-r--r-- | xmake/modules/private/xrepo/action/env.lua | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/xmake/modules/private/xrepo/action/env.lua b/xmake/modules/private/xrepo/action/env.lua index cb6936006..297a0717c 100644 --- a/xmake/modules/private/xrepo/action/env.lua +++ b/xmake/modules/private/xrepo/action/env.lua @@ -285,15 +285,29 @@ function _get_env_script(envs, shell, del) elseif shell == "cmd" then prefix = "@set \"" suffix = "\"" + elseif shell:endswith("sh") then + if del then + prefix = "unset " + connector = "" + else + prefix = "export " + connector = "='" + suffix = "'" + end end + local exceptions = hashset.of("_", "PS1", "PROMPT") local ret = "" if del then for name, _ in pairs(envs) do - ret = ret .. prefix .. name .. connector .. default .. suffix .. "\n" + if not exceptions:has(name) then + ret = ret .. prefix .. name .. connector .. default .. suffix .. "\n" + end end else for name, value in pairs(envs) do - ret = ret .. prefix .. name .. connector .. value .. suffix .. "\n" + if not exceptions:has(name) then + ret = ret .. prefix .. name .. connector .. value .. suffix .. "\n" + end end end return ret |
