Skip to content

Commit

Permalink
which: handle windows uppercase filename corner case
Browse files Browse the repository at this point in the history
  • Loading branch information
scivision committed Apr 19, 2024
1 parent 4301be3 commit 83248db
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions +stdlib/+fileio/which.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
function exe = which(filename, fpath)
%% which like Python shutil.which, find executable in fpath or env var PATH
%% which()
% like Python shutil.which, find executable in fpath or env var PATH
% does not resolve path.
% That is, can return relative path if executable is in:
% * (Windows) in cwd
% * (all) fpath or Path contains relative paths
arguments
filename (1,1) string {mustBeNonzeroLengthText}
fpath (1,:) string = getenv('PATH')
Expand All @@ -11,7 +16,7 @@
% Windows executable filename doesn't necessarily need .exe,
% particularly for WSL executables that is_exe() will detect from
% native Windows Matlab.
if ~endsWith(filename, ".exe")
if ~endsWith(lower(filename), ".exe")
names(2) = filename + ".exe";
end
end
Expand Down

0 comments on commit 83248db

Please sign in to comment.