Skip to content

Commit 2b04195

Browse files
committed
which: pass use_java args, needed for WSL on Windows
1 parent 2a42857 commit 2b04195

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

+stdlib/which.m

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function exe = which(filename, fpath)
1+
function exe = which(filename, fpath, use_java)
22
%% which()
33
% like Python shutil.which, find executable in fpath or env var PATH
44
% does not resolve path.
@@ -8,6 +8,7 @@
88
arguments
99
filename (1,1) string {mustBeNonzeroLengthText}
1010
fpath (1,:) string = getenv('PATH')
11+
use_java (1,1) logical = false
1112
end
1213

1314
names = filename;
@@ -24,7 +25,7 @@
2425
% directory/filename given
2526
for exe = names
2627

27-
if stdlib.is_absolute(exe) && stdlib.is_exe(exe)
28+
if stdlib.is_absolute(exe, use_java) && stdlib.is_exe(exe, use_java)
2829
return
2930
end
3031

@@ -47,7 +48,7 @@
4748

4849
for p = fpath
4950
exe = stdlib.join(p, name);
50-
if stdlib.is_exe(exe)
51+
if stdlib.is_exe(exe, use_java)
5152
return
5253
end
5354
end

test/TestWSL.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function test_is_exe_which_wsl(tc)
3535

3636
tc.verifyTrue(stdlib.is_exe(out), "is_exe() failed to detect WSL executable " + out)
3737

38-
wsl_exe = stdlib.which(out);
38+
wsl_exe = stdlib.which(out, [], true);
3939
tc.verifyNotEmpty(wsl_exe, "which() failed to detect WSL executable " + out)
4040

4141
end

0 commit comments

Comments
 (0)