]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
whereis: add search scope listing option
authorSami Kerola <kerolasa@iki.fi>
Sat, 16 Mar 2013 20:12:49 +0000 (20:12 +0000)
committerKarel Zak <kzak@redhat.com>
Tue, 19 Mar 2013 15:02:32 +0000 (16:02 +0100)
Mostly useful when debugging why the command does, or does not, work.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
misc-utils/whereis.1
misc-utils/whereis.c

index 86e6a39b66166a045e86053b66bf20090124e599..9b33999c484989d22c8efde729f057785fc7619b 100644 (file)
@@ -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
index 97ec45cb28eb95830cb3a2654059a5b63c6a7ec1..0f14267f3e8082bcd84b73088a9013cd78bd477e 100644 (file)
@@ -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;
 }