diff options
| author | star9029 <[email protected]> | 2025-09-13 07:31:45 +0800 |
|---|---|---|
| committer | star9029 <[email protected]> | 2025-09-13 07:31:45 +0800 |
| commit | db0a39763225e745d11b2f994b9366258ad42e31 (patch) | |
| tree | 75268e035df7935781ae67b07fdd3174713d1416 | |
| parent | e6c092279a2306dc56567d034013c5f0ff4e4b15 (diff) | |
Support nushell for xrepo env
| -rw-r--r-- | xmake/core/base/tty.lua | 40 | ||||
| -rw-r--r-- | xmake/modules/private/xrepo/action/env.lua | 12 |
2 files changed, 31 insertions, 21 deletions
diff --git a/xmake/core/base/tty.lua b/xmake/core/base/tty.lua index 56d6f9942..8df056d61 100644 --- a/xmake/core/base/tty.lua +++ b/xmake/core/base/tty.lua @@ -154,26 +154,30 @@ function tty.shell() 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" + if os.getenv("NU_VERSION") then + shell = "nu" + else + if subhost == "windows" then + if os.getenv("PROMPT") then + shell = "cmd" else - shell = "powershell" + local ok, result = os.iorun("pwsh -v") + if ok then + shell = "pwsh" + else + shell = "powershell" + end end - end - else - shell = os.getenv("XMAKE_SHELL") - if not shell then - shell = os.getenv("SHELL") - if shell then - for _, shellname in ipairs({"zsh", "bash", "sh"}) do - if shell:find(shellname) then - shell = shellname - break + else + shell = os.getenv("XMAKE_SHELL") + if not shell then + 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 diff --git a/xmake/modules/private/xrepo/action/env.lua b/xmake/modules/private/xrepo/action/env.lua index e116847b2..0c77e68a3 100644 --- a/xmake/modules/private/xrepo/action/env.lua +++ b/xmake/modules/private/xrepo/action/env.lua @@ -380,8 +380,14 @@ end -- run shell function _run_shell(envs) local shell = os.shell() + local args = table.wrap(option.get("arguments")) if shell == "pwsh" or shell == "powershell" then - os.execv("pwsh", option.get("arguments"), {envs = envs}) + os.execv("pwsh", args, {envs = envs}) + elseif shell == "nu" then + if #args ~=0 then + table.insert(args, 1, "-c") + end + os.execv("nu", args, {envs = envs}) elseif shell:endswith("sh") then local prompt = _get_prompt() local ps1 = os.getenv("PS1") @@ -392,11 +398,11 @@ function _run_shell(envs) else prompt = prompt .. " > " end - os.execv(shell, option.get("arguments"), {envs = table.join({PS1 = prompt}, envs)}) + os.execv(shell, args, {envs = table.join({PS1 = prompt}, envs)}) elseif shell == "cmd" or is_host("windows") then local prompt = _get_prompt() prompt = prompt .. " $P$G" - local args = table.join({"/k", "set PROMPT=" .. prompt}, option.get("arguments")) + local args = table.join({"/k", "set PROMPT=" .. prompt}, args) os.execv("cmd", args, {envs = envs}) else assert("shell not found!") |
