Bug 228566 - which fails to handle -a or -s as documented in manpage
Summary: which fails to handle -a or -s as documented in manpage
Status: Closed Not A Bug
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-bugs mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-05-28 15:37 UTC by Bjoern A. Zeeb
Modified: 2018-05-28 15:58 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Bjoern A. Zeeb freebsd_committer 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 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 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 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