diff options
-rw-r--r-- | misc-utils/whereis.1 | 11 | ||||
-rw-r--r-- | misc-utils/whereis.c | 29 |
2 files changed, 39 insertions, 1 deletions
diff --git a/misc-utils/whereis.1 b/misc-utils/whereis.1 index 86e6a39b6..9b33999c4 100644 --- a/misc-utils/whereis.1 +++ b/misc-utils/whereis.1 @@ -91,7 +91,16 @@ be used when any of the or .BR \-S options is used. - +.IP "\fB\-l" +Output list of effective lookup paths the +.B whereis +is using. When non of +.BR \-B , +.BR \-M , +or +.BR \-S +is specified the option will out hard coded paths that the command was +able to find on system. .SH EXAMPLE To find all files in .B /usr/bin diff --git a/misc-utils/whereis.c b/misc-utils/whereis.c index 97ec45cb2..0f14267f3 100644 --- a/misc-utils/whereis.c +++ b/misc-utils/whereis.c @@ -176,6 +176,7 @@ static void __attribute__((__noreturn__)) usage(FILE *out) " -s search only for sources\n" " -S <dirs> define sources lookup path\n" " -u search for unusual entries\n" + " -l output effective lookup paths\n" " -V output version information and exit\n" " -h display this help and exit\n\n"), out); @@ -436,6 +437,29 @@ static void lookup(const char *pattern, struct wh_dirlist *ls, int want) return; } +static void list_dirlist(struct wh_dirlist *ls) +{ + while (ls) { + if (ls->path) { + switch (ls->type) { + case BIN_DIR: + printf("bin: "); + break; + case MAN_DIR: + printf("man: "); + break; + case SRC_DIR: + printf("src: "); + break; + default: + abort(); + } + printf("%s\n", ls->path); + } + ls = ls->next; + } +} + int main(int argc, char **argv) { struct wh_dirlist *ls = NULL; @@ -515,6 +539,9 @@ int main(int argc, char **argv) case 's': want = want == ALL_DIRS ? SRC_DIR : want | SRC_DIR; break; + case 'l': + list_dirlist(ls); + break; case 'V': printf(UTIL_LINUX_VERSION); return EXIT_SUCCESS; @@ -526,6 +553,8 @@ int main(int argc, char **argv) } } + + DBG(printf("DONE")); free_dirlist(&ls, ALL_DIRS); return EXIT_SUCCESS; } |