diff --git a/+stdlib/which.m b/+stdlib/which.m index 3e45a6a..bf3cade 100644 --- a/+stdlib/which.m +++ b/+stdlib/which.m @@ -1,4 +1,4 @@ -function exe = which(filename, fpath) +function exe = which(filename, fpath, use_java) %% which() % like Python shutil.which, find executable in fpath or env var PATH % does not resolve path. @@ -8,6 +8,7 @@ arguments filename (1,1) string {mustBeNonzeroLengthText} fpath (1,:) string = getenv('PATH') + use_java (1,1) logical = false end names = filename; @@ -24,7 +25,7 @@ % directory/filename given for exe = names - if stdlib.is_absolute(exe) && stdlib.is_exe(exe) + if stdlib.is_absolute(exe, use_java) && stdlib.is_exe(exe, use_java) return end @@ -47,7 +48,7 @@ for p = fpath exe = stdlib.join(p, name); - if stdlib.is_exe(exe) + if stdlib.is_exe(exe, use_java) return end end diff --git a/test/TestWSL.m b/test/TestWSL.m index 918da9a..b466b2c 100644 --- a/test/TestWSL.m +++ b/test/TestWSL.m @@ -35,7 +35,7 @@ function test_is_exe_which_wsl(tc) tc.verifyTrue(stdlib.is_exe(out), "is_exe() failed to detect WSL executable " + out) -wsl_exe = stdlib.which(out); +wsl_exe = stdlib.which(out, [], true); tc.verifyNotEmpty(wsl_exe, "which() failed to detect WSL executable " + out) end