Skip to content

Commit 8069f62

Browse files
committed
fix run script
1 parent 8241b15 commit 8069f62

File tree

2 files changed

+27
-20
lines changed

2 files changed

+27
-20
lines changed

xmake/core/base/tty.lua

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -153,28 +153,34 @@ end
153153
function tty.shell()
154154
local shell = tty._SHELL
155155
if shell == nil then
156-
local subhost = xmake._SUBHOST
157-
if subhost == "windows" then
158-
if os.getenv("PROMPT") then
159-
shell = "cmd"
160-
else
161-
local ok, result = os.iorun("pwsh -v")
162-
if ok then
163-
shell = "pwsh"
156+
if os.getenv("NU_VERSION") then
157+
shell = "nu"
158+
end
159+
if not shell then
160+
local subhost = xmake._SUBHOST
161+
if subhost == "windows" then
162+
if os.getenv("PROMPT") then
163+
shell = "cmd"
164164
else
165-
shell = "powershell"
165+
local ok, result = os.iorun("pwsh -v")
166+
if ok then
167+
shell = "pwsh"
168+
else
169+
shell = "powershell"
170+
end
166171
end
167172
end
168-
else
173+
end
174+
if not shell then
169175
shell = os.getenv("XMAKE_SHELL")
170-
if not shell then
171-
shell = os.getenv("SHELL")
172-
if shell then
173-
for _, shellname in ipairs({"zsh", "bash", "sh"}) do
174-
if shell:find(shellname) then
175-
shell = shellname
176-
break
177-
end
176+
end
177+
if not shell then
178+
shell = os.getenv("SHELL")
179+
if shell then
180+
for _, shellname in ipairs({"zsh", "bash", "sh"}) do
181+
if shell:find(shellname) then
182+
shell = shellname
183+
break
178184
end
179185
end
180186
end
@@ -445,3 +451,4 @@ end
445451

446452
-- return module
447453
return tty
454+

xmake/modules/utils/run_script.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@ function _run_script(script, args, opt)
6666
-- run the given lua script file (xmake lua /tmp/script.lua)
6767
script_type, script_name = "given lua script file", path.relative(script)
6868
func = import(path.basename(script), {rootdir = path.directory(script), anonymous = true})
69-
elseif os.isfile(path.join(os.scriptdir(), "scripts", script .. ".lua")) then
69+
elseif os.isfile(path.join(os.programdir(), "plugins", "lua", "scripts", script .. ".lua")) then
7070

7171
-- run builtin lua script (xmake lua echo "hello xmake")
7272
script_type, script_name = "builtin lua script", script
73-
func = import("scripts." .. script, {anonymous = true})
73+
func = import("scripts." .. script, {anonymous = true, rootdir = path.join(os.programdir(), "plugins", "lua")})
7474
else
7575

7676
-- attempt to find the builtin module

0 commit comments

Comments
 (0)