]> err.no Git - util-linux/commitdiff
findmnt: fix exit code
authorKarel Zak <kzak@redhat.com>
Mon, 22 Nov 2010 23:26:49 +0000 (00:26 +0100)
committerKarel Zak <kzak@redhat.com>
Mon, 3 Jan 2011 11:28:46 +0000 (12:28 +0100)
... returns 1 if nothing printed.

Signed-off-by: Karel Zak <kzak@redhat.com>
misc-utils/findmnt.c

index c1b80dc8c17f9dee6e8eef5a44a0b07bb0e47cef..99af97836888c0df2ed16e526f350a2c2bcf555c 100644 (file)
@@ -499,7 +499,7 @@ int main(int argc, char *argv[])
        struct tt *tt = NULL;
        int tt_flags = 0;
 
-       int i, c, rc = EXIT_FAILURE;
+       int i, c, nlines = 0, rc = EXIT_FAILURE;
 
        struct option longopts[] = {
            { "ascii",        0, 0, 'a' },
@@ -720,6 +720,7 @@ int main(int argc, char *argv[])
                while((fs = get_next_fs(tb, itr))) {
                        if (!add_line(tt, fs, NULL))
                                goto leave;
+                       nlines++;
                        if (flags & FL_FIRSTONLY)
                                break;
                }
@@ -729,7 +730,9 @@ int main(int argc, char *argv[])
         * Print the output table
         */
        tt_print_table(tt);
-       rc = EXIT_SUCCESS;
+
+       if (is_listall_mode() || nlines)
+               rc = EXIT_SUCCESS;
 leave:
        tt_free_table(tt);