chiark / gitweb /
journalctl: honour -n if -F is used
authorLennart Poettering <lennart@poettering.net>
Thu, 18 Oct 2012 20:55:12 +0000 (22:55 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 18 Oct 2012 21:35:44 +0000 (23:35 +0200)
src/journal/journalctl.c

index 5980eb0..7564c48 100644 (file)
@@ -926,11 +926,16 @@ int main(int argc, char *argv[]) {
                 SD_JOURNAL_FOREACH_UNIQUE(j, data, size) {
                         const void *eq;
 
+                        if (arg_lines > 0 && n_shown >= arg_lines)
+                                break;
+
                         eq = memchr(data, '=', size);
                         if (eq)
                                 printf("%.*s\n", (int) (size - ((const uint8_t*) eq - (const uint8_t*) data + 1)), (const char*) eq + 1);
                         else
                                 printf("%.*s\n", (int) size, (const char*) data);
+
+                        n_shown ++;
                 }
 
                 r = 0;