@@ -43,6 +43,8 @@ function sandbox_lib_detect_find_program._do_check(program, opt)
43
43
-- do not attempt to run program? check it fastly
44
44
if opt .norun then
45
45
return os .isfile (program )
46
+ elseif opt .norunfile and path .is_absolute (program ) and os .isfile (program ) then
47
+ return true
46
48
end
47
49
48
50
-- no check script? attempt to run it directly
@@ -200,7 +202,11 @@ function sandbox_lib_detect_find_program._find(name, paths, opt)
200
202
if not program_name :endswith (" .exe" ) then
201
203
program_name = program_name .. " .exe"
202
204
end
203
- program_path = winos .registry_query (" HKEY_LOCAL_MACHINE\\ SOFTWARE\\ Microsoft\\ Windows\\ CurrentVersion\\ App Paths\\ " .. program_name )
205
+ if path .is_absolute (program_name ) and os .isfile (program_name ) then
206
+ program_path = program_name
207
+ else
208
+ program_path = winos .registry_query (" HKEY_LOCAL_MACHINE\\ SOFTWARE\\ Microsoft\\ Windows\\ CurrentVersion\\ App Paths\\ " .. program_name )
209
+ end
204
210
if program_path then
205
211
program_path = program_path :trim ()
206
212
if os .isexec (program_path ) then
@@ -211,10 +217,19 @@ function sandbox_lib_detect_find_program._find(name, paths, opt)
211
217
end
212
218
end
213
219
else
214
- -- attempt to find it use `which program` command
215
- local ok , program_path = os .iorunv (" which" , {name })
216
- if ok and program_path then
217
- program_path = program_path :trim ()
220
+ if path .is_absolute (name ) and os .isfile (name ) then
221
+ program_path = name
222
+ else
223
+ -- attempt to find it use `which program` command
224
+ local ok , result = os .iorunv (" which" , {name })
225
+ if ok and result then
226
+ program_path = result :trim ()
227
+ else
228
+ program_path = nil
229
+ end
230
+ end
231
+
232
+ if program_path then
218
233
local program_path_real = sandbox_lib_detect_find_program ._check (program_path , opt )
219
234
if program_path_real then
220
235
return program_path_real
282
297
-- - opt.paths the program paths (e.g. dirs, paths, winreg paths, script paths)
283
298
-- - opt.check the check script or command
284
299
-- - opt.norun do not attempt to run program to check program fastly
300
+ -- - opt.norunfile do not attempt to run program to check program if it's valid file path.
285
301
-- - opt.system true: only find it from system, false: only find it from xmake/packages
286
302
--
287
303
-- @return the program name or path
0 commit comments