178
178
-- find program
179
179
function sandbox_lib_detect_find_program ._find (name , paths , opt )
180
180
181
- -- valid program file?
182
- if path .is_absolute (name ) and os .isfile (name ) then
183
- return name
184
- end
185
-
186
181
-- attempt to find it from the given directories
187
182
local program_path = sandbox_lib_detect_find_program ._find_from_paths (name , paths , opt )
188
183
if program_path and opt .system ~= false then
@@ -205,7 +200,11 @@ function sandbox_lib_detect_find_program._find(name, paths, opt)
205
200
if not program_name :endswith (" .exe" ) then
206
201
program_name = program_name .. " .exe"
207
202
end
208
- program_path = winos .registry_query (" HKEY_LOCAL_MACHINE\\ SOFTWARE\\ Microsoft\\ Windows\\ CurrentVersion\\ App Paths\\ " .. program_name )
203
+ if path .is_absolute (program_name ) and os .isfile (program_name ) then
204
+ program_path = program_name
205
+ else
206
+ program_path = winos .registry_query (" HKEY_LOCAL_MACHINE\\ SOFTWARE\\ Microsoft\\ Windows\\ CurrentVersion\\ App Paths\\ " .. program_name )
207
+ end
209
208
if program_path then
210
209
program_path = program_path :trim ()
211
210
if os .isexec (program_path ) then
@@ -216,10 +215,19 @@ function sandbox_lib_detect_find_program._find(name, paths, opt)
216
215
end
217
216
end
218
217
else
219
- -- attempt to find it use `which program` command
220
- local ok , program_path = os .iorunv (" which" , {name })
221
- if ok and program_path then
222
- program_path = program_path :trim ()
218
+ if path .is_absolute (name ) and os .isfile (name ) then
219
+ program_path = name
220
+ else
221
+ -- attempt to find it use `which program` command
222
+ local ok , result = os .iorunv (" which" , {name })
223
+ if ok and result then
224
+ program_path = result :trim ()
225
+ else
226
+ program_path = nil
227
+ end
228
+ end
229
+
230
+ if program_path then
223
231
local program_path_real = sandbox_lib_detect_find_program ._check (program_path , opt )
224
232
if program_path_real then
225
233
return program_path_real
0 commit comments