whereis: reset search mask more carefully
# whereis -m cal -M /usr/share/man/man1/ -f ls cal: /usr/share/man/man1/cal.1.gz /usr/share/man/man1p/cal.1p.gz ls: /usr/bin/ls /usr/share/man/man1/ls.1.gz the -M also resets the search mask, so for 'ls' it returns also binaries. That's bug. Expected result is: # ./whereis -m cal -M /usr/share/man/man1/ -f ls cal: /usr/share/man/man1/cal.1.gz /usr/share/man/man1p/cal.1p.gz ls: /usr/share/man/man1/ls.1.gz the search mask has to be sensitive only to -b -m -s options, otherwise the semantic is pretty messy. Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
parent
3635f53ca2
commit
f4802c9011
|
@ -56,14 +56,35 @@ in the places specified by
|
|||
.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.
|
||||
|
|
|
@ -491,7 +491,7 @@ int main(int argc, char **argv)
|
|||
{
|
||||
struct wh_dirlist *ls = NULL;
|
||||
int want = ALL_DIRS;
|
||||
int i;
|
||||
int i, want_resetable = 0;
|
||||
|
||||
setlocale(LC_ALL, "");
|
||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
|
@ -519,21 +519,16 @@ int main(int argc, char **argv)
|
|||
|
||||
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:
|
||||
/*
|
||||
* The lookup mask ("want") is cumulative and it's
|
||||
* resetable only when it has been already used.
|
||||
*
|
||||
* whereis -m ls -b tr
|
||||
*
|
||||
* 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++) {
|
||||
|
@ -570,12 +565,24 @@ int main(int argc, char **argv)
|
|||
&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':
|
||||
|
|
Loading…
Reference in New Issue