Skip to content

Commit 24bc10c

Browse files
committed
is_exe: correct array logic
1 parent 40f1092 commit 24bc10c

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

+stdlib/is_exe.m

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,22 @@
99
% need to have string array type for p(:)
1010

1111
try
12+
1213
if isunix
1314
props = ["UserExecute", "GroupExecute", "OtherExecute"];
1415
else
1516
props = "Readable";
1617
end
17-
t = getPermissions(filePermissions(p), props);
18-
ok = isfile(p(:)) & any(t{:,:}, 2);
18+
19+
p = p(:);
20+
i = isfile(p);
21+
ok(size(p)) = false;
22+
if ~any(i), return, end
23+
24+
t(i, :) = getPermissions(filePermissions(p(i)), props);
25+
26+
ok(i) = isfile(p(i)) & any(t{i,:}, 2);
27+
1928
catch e
2029
switch e.identifier
2130
case {'MATLAB:UndefinedFunction', 'Octave:undefined-function'}

test/TestIsExe.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ function test_is_exe(tc, p)
1111

1212
function test_matlab_exe(tc)
1313

14-
f = fullfile(matlabroot, "bin", "matlab");
14+
f = fullfile(matlabroot, "bin/matlab");
1515
if ispc()
1616
f = f + ".exe";
1717
end

0 commit comments

Comments
 (0)