From 932d154c8d8adeb1acf23d7a637fc7c18dd29d83 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Tue, 23 Nov 2010 00:26:49 +0100 Subject: [PATCH] findmnt: fix exit code ... returns 1 if nothing printed. Signed-off-by: Karel Zak --- misc-utils/findmnt.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/misc-utils/findmnt.c b/misc-utils/findmnt.c index c1b80dc8..99af9783 100644 --- a/misc-utils/findmnt.c +++ b/misc-utils/findmnt.c @@ -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); -- 2.39.5