Bug 228566

Summary: which fails to handle -a or -s as documented in manpage
Product: Base System Reporter: Bjoern A. Zeeb <bz>
Component: binAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed Not A Bug    
Severity: Affects Only Me CC: 0mp, bz
Priority: ---    
Version: CURRENT   
Hardware: Any   
OS: Any   

Description Bjoern A. Zeeb freebsd_committer freebsd_triage 2018-05-28 15:37:47 UTC
which(1) documents a -a and a -s option yet:

% which -a which
-a: Command not found.
which: shell built-in command.

% which -s which
-s: Command not found.
which: shell built-in command.

% which -a true
-a: Command not found.
/usr/bin/true

% which -s true
-s: Command not found.
/usr/bin/true


Seems this has been broken/unsupported in a long time.  Can someone either fix the code or the man page?
Comment 1 Mateusz Piotrowski freebsd_committer freebsd_triage 2018-05-28 15:43:11 UTC
(In reply to Bjoern A. Zeeb from comment #0)

It is not which(1) that is not working as specified in the manual. It looks like your are using tcsh/csh, which seems to not implement those "-a" and "-s" flags. Here's a fragment of the tcsh(1) manual:

> which command (+)
>               Displays the command that will be executed by the shell after
>               substitutions, path searching, etc.  The builtin command is
>               just like which(1), but it correctly reports tcsh aliases and
>               builtins and is 10 to 100 times faster.  See also the which-
>               command editor command.

It looks like everything works as intended.
Comment 2 Mateusz Piotrowski freebsd_committer freebsd_triage 2018-05-28 15:45:46 UTC
Try running which(1) like this:

    % /usr/bin/which -a true
Comment 3 Bjoern A. Zeeb freebsd_committer freebsd_triage 2018-05-28 15:58:51 UTC
Argh.  Thanks.  That's what happens if you don't even read the error messages your are pasting and not have your normal environment.  PEBKAC