Mercurial > octave
changeset 27903:f7279dd915d8
what.m: Check file / folder status before returning results (bug #57531).
* what.m: Add isfile() or isfolder() checks to make sure that names have
the correct identity.
author | Rik <rik@octave.org> |
---|---|
date | Fri, 03 Jan 2020 09:43:43 -0800 |
parents | 32f4a15c77c7 |
children | 121d33ab44bc |
files | scripts/miscellaneous/what.m |
diffstat | 1 files changed, 20 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/miscellaneous/what.m Fri Jan 03 09:32:02 2020 -0800 +++ b/scripts/miscellaneous/what.m Fri Jan 03 09:43:43 2020 -0800 @@ -110,17 +110,29 @@ ## mdl, slx, and p are ignored (no if test) since they are not implemented [~, f, e] = fileparts (nm); if (strcmp (e, ".m")) - w.m{end+1} = nm; + if (isfile (fullfile (dir, nm))) + w.m{end+1} = nm; + endif elseif (strcmp (e, ".mat")) - w.mat{end+1} = nm; + if (isfile (fullfile (dir, nm))) + w.mat{end+1} = nm; + endif elseif (strcmp (e, ".oct")) - w.oct{end+1} = nm; + if (isfile (fullfile (dir, nm))) + w.oct{end+1} = nm; + endif elseif (strcmp (e, mexext ())) - w.mex{end+1} = nm; - elseif (nm(1) == "@" && isfolder (fullfile (dir, nm))) - w.classes{end+1} = nm; - elseif (nm(1) == "+" && isfolder (fullfile (dir, nm))) - w.packages{end+1} = nm; + if (isfile (fullfile (dir, nm))) + w.mex{end+1} = nm; + endif + elseif (nm(1) == "@") + if (isfolder (fullfile (dir, nm))) + w.classes{end+1} = nm; + endif + elseif (nm(1) == "+") + if (isfolder (fullfile (dir, nm))) + w.packages{end+1} = nm; + endif endif endfor