Skip to content

Commit eb64a4e

Browse files
committed
which: simplify types
1 parent 24bc10c commit eb64a4e

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

+stdlib/which.m

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,20 @@
99

1010
function exe = which(cmd, fpath, find_all)
1111
arguments
12-
cmd {mustBeTextScalar}
12+
cmd (1,1) string
1313
fpath (1,:) string = string.empty
1414
find_all (1,1) logical = false
1515
end
1616

17-
if find_all
18-
exe = string.empty;
19-
else
20-
exe = '';
21-
end
17+
exe = string.empty;
2218

2319
%% on Windows, append .exe if not suffix is given
2420
if ispc() && strempty(stdlib.suffix(cmd))
25-
cmd = strcat(cmd, '.exe');
21+
cmd = cmd + ".exe";
2622
end
2723
%% full filename was given
28-
if isfile(cmd) && stdlib.is_exe(cmd)
24+
if stdlib.is_exe(cmd)
25+
% is_exe implies isfile
2926
exe = cmd;
3027
return
3128
end
@@ -65,5 +62,3 @@
6562
end
6663

6764
end
68-
69-
%!assert(~isempty(which("octave", [], false)))

test/TestWhich.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
properties (TestParameter)
44
mexe = {matlabroot + "/bin/matlab", ...
5-
fullfile(matlabroot, 'bin', 'matlab')}
5+
fullfile(matlabroot, 'bin/matlab')}
66
end
77

88
methods (Test, TestTags="impure")
@@ -33,9 +33,9 @@ function test_which_name(tc)
3333

3434
function test_which_absolute(tc, mexe)
3535

36-
r = mexe;
36+
r = string(mexe);
3737
if ispc()
38-
r = strcat(r, '.exe');
38+
r = r + ".exe";
3939
end
4040

4141
tc.verifyEqual(stdlib.which(mexe), r)

0 commit comments

Comments
 (0)