diff options
| author | xq114 <[email protected]> | 2021-04-16 13:24:11 +0800 |
|---|---|---|
| committer | xq114 <[email protected]> | 2021-04-16 13:24:11 +0800 |
| commit | 042b301bd2042cf19207096ceafc30be3dbd0658 (patch) | |
| tree | 3701a9c5171a129b4107b99f7d98eb07850f67d1 /xmake/core/base/tty.lua | |
| parent | 0ba602c1fdb417188c215ccda4b342549da9924d (diff) | |
add cache to tty.shell
Diffstat (limited to 'xmake/core/base/tty.lua')
| -rw-r--r-- | xmake/core/base/tty.lua | 42 |
1 files changed, 24 insertions, 18 deletions
diff --git a/xmake/core/base/tty.lua b/xmake/core/base/tty.lua index b18ef540a..30b6abb99 100644 --- a/xmake/core/base/tty.lua +++ b/xmake/core/base/tty.lua @@ -127,28 +127,34 @@ end -- get shell name function tty.shell() - local shell = os.getenv("SHELL") - if shell then - for _, shellname in ipairs({"zsh", "bash", "sh"}) do - if shell:find(shellname) then - return shellname + local shell = tty._SHELL + if shell == nil then + local subhost = xmake._SUBHOST + if subhost == "windows" then + if os.getenv("PROMPT") then + shell = "cmd" + else + local ok, result = os.iorun("pwsh -v") + if ok then + shell = "pwsh" + else + shell = "powershell" + end end - end - end - local subhost = xmake._SUBHOST - if subhost == "windows" then - if os.getenv("PROMPT") then - return "cmd" else - local ok, result = os.iorun("pwsh -v") - if ok then - return "pwsh" - else - return "powershell" + shell = os.getenv("SHELL") + if shell then + for _, shellname in ipairs({"zsh", "bash", "sh"}) do + if shell:find(shellname) then + shell = shellname + break + end + end end end + tty._SHELL = shell or "sh" end - return "sh" + return tty._SHELL end -- get terminal name @@ -219,7 +225,7 @@ function tty.term() end tty._TERM = term or "unknown" end - return term + return tty._TERM end -- has emoji? |
