comparison scripts/help/which.m @ 31444:2569c40924e7 stable

which.m: Add warning for unimplemented '-all' option (bug #32088) * which.m: Check for use of '-all' and issue a warning to the user instead of silently ignoring the option. Remove any instance of '-all' from varargin and adjust nargin accordingly. Add a BIST to verify the warning is triggered and a FIXME note referring to the bug report.
author Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
date Tue, 15 Nov 2022 17:40:23 -0500
parents 796f54d4ddbf
children fd29c7a50a78
comparison
equal deleted inserted replaced
31439:38139b13192c 31444:2569c40924e7
34 34
35 function varargout = which (varargin) 35 function varargout = which (varargin)
36 36
37 if (nargin == 0 || ! iscellstr (varargin)) 37 if (nargin == 0 || ! iscellstr (varargin))
38 print_usage (); 38 print_usage ();
39 endif
40
41 ## FIXME: "-all" option not implemented. Warn user that only the first
42 ## result found will be returned. See bug #32088.
43 if (any (isall = strcmpi (varargin, "-all")))
44 warning (["which: '-all' not yet implemented - only the first result ", ...
45 "will be returned\n"]);
46 varargin = varargin(! isall);
47 nargin = nargin - sum (isall);
39 endif 48 endif
40 49
41 m = __which__ (varargin{:}); 50 m = __which__ (varargin{:});
42 51
43 ## Check whether each name is a variable, variables take precedence over 52 ## Check whether each name is a variable, variables take precedence over
111 %! str = which ("fftw"); 120 %! str = which ("fftw");
112 %! assert (str(end-7:end), "fftw.oct"); 121 %! assert (str(end-7:end), "fftw.oct");
113 122
114 %!error <Invalid call> which () 123 %!error <Invalid call> which ()
115 %!error <Invalid call> which (1) 124 %!error <Invalid call> which (1)
125 %!warning <'-all' not yet implemented> which ("1", "-all")
116 126