Skip to content

Commit a280712

Browse files
committed
which: handle windows uppercase filename corner case
1 parent 65a8109 commit a280712

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

+stdlib/+fileio/which.m

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
function exe = which(filename, fpath)
2-
%% which like Python shutil.which, find executable in fpath or env var PATH
2+
%% which()
3+
% like Python shutil.which, find executable in fpath or env var PATH
4+
% does not resolve path.
5+
% That is, can return relative path if executable is in:
6+
% * (Windows) in cwd
7+
% * (all) fpath or Path contains relative paths
38
arguments
49
filename (1,1) string {mustBeNonzeroLengthText}
510
fpath (1,:) string = getenv('PATH')
@@ -11,7 +16,7 @@
1116
% Windows executable filename doesn't necessarily need .exe,
1217
% particularly for WSL executables that is_exe() will detect from
1318
% native Windows Matlab.
14-
if ~endsWith(filename, ".exe")
19+
if ~endsWith(lower(filename), ".exe")
1520
names(2) = filename + ".exe";
1621
end
1722
end

0 commit comments

Comments
 (0)