.B $PATH
and
.BR $MANPATH .
+
+The search restrinctions (options \fB\-b\fP, \fB\-m\fP and \fB\-s\fP) are
+cumulative and always applied for the next \fIname\fP patterns specified on
+command line. The first search restrinction resets the search mask. For example
+.RS
+.sp
+.B "whereis -bm ls tr -m gcc"
+.sp
+.RE
+searchs for "ls" and "tr" binaries and man pages, and "gcc" man pages only.
+
+The options \fB\-B\fP, \fB\-M\fP and \fB\-S\fP resets search paths for the next
+\fIname\fP patterns. For example
+.RS
+.sp
+.B "whereis -m ls -M /usr/share/man/man1 -f cal"
+.sp
+.RE
+searchs for "ls" man pages in all default paths, but for "cal" in
+/usr/share/man/man1 directory only.
+
.SH OPTIONS
.TP
.IP \fB\-b\fP
-Search only for binaries.
+Search for binaries.
.IP \fB\-m\fP
-Search only for manuals.
+Search for manuals.
.IP \fB\-s\fP
-Search only for sources.
+Search for sources.
.IP \fB\-u\fP
Only show the command names that have unusual entries. A command is said to be
unusual if it does not have just one entry of each explicitly requested type.
{
struct wh_dirlist *ls = NULL;
int want = ALL_DIRS;
- int i;
+ int i, want_resetable = 0;
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
if (*arg != '-') {
lookup(arg, ls, want);
- continue;
- }
-
- if (i > 1 && *argv[i - 1] != '-') {
- /* the list of search patterns has been interupted by
- * any non-pattern option, then reset the mask for
- * wanted directories. For example:
- *
- * whereis -m ls -b tr
+ /*
+ * The lookup mask ("want") is cumulative and it's
+ * resetable only when it has been already used.
*
- * search for "ls" in mandirs and "tr" in bindirs
+ * whereis -b -m foo :'foo' mask=BIN|MAN
+ * whereis -b foo bar :'foo' and 'bar' mask=BIN|MAN
+ * whereis -b foo -m bar :'foo' mask=BIN; 'bar' mask=MAN
*/
- DBG(ARGV, ul_debug("list of search patterns interupted "
- "by non-pattern"));
- want = ALL_DIRS;
+ want_resetable = 1;
+ continue;
}
for (++arg; arg && *arg; arg++) {
&ls, &i, argc, argv, SRC_DIR);
break;
case 'b':
+ if (want_resetable) {
+ want = ALL_DIRS;
+ want_resetable = 0;
+ }
want = want == ALL_DIRS ? BIN_DIR : want | BIN_DIR;
break;
case 'm':
+ if (want_resetable) {
+ want = ALL_DIRS;
+ want_resetable = 0;
+ }
want = want == ALL_DIRS ? MAN_DIR : want | MAN_DIR;
break;
case 's':
+ if (want_resetable) {
+ want = ALL_DIRS;
+ want_resetable = 0;
+ }
want = want == ALL_DIRS ? SRC_DIR : want | SRC_DIR;
break;
case 'l':