diff options
author | Jan Janssen <medhefgo@web.de> | 2014-08-31 11:12:22 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2014-08-31 09:18:44 -0400 |
commit | 48382487666af141bb4385ceb5fb73c4147f6141 (patch) | |
tree | 9d3ed6b2492abeb5b625f98c088e9da9dd04f894 | |
parent | 8e07fc41f86d41e68c5663b2a3c620a0adedcc11 (diff) |
journalctl: Allow to disable line cap with --lines=all
-rw-r--r-- | man/journalctl.xml | 13 | ||||
-rw-r--r-- | src/journal/journalctl.c | 42 |
2 files changed, 30 insertions, 25 deletions
diff --git a/man/journalctl.xml b/man/journalctl.xml index d4e031619a..acd75a6370 100644 --- a/man/journalctl.xml +++ b/man/journalctl.xml @@ -189,9 +189,9 @@ that the pager will not buffer logs of unbounded size. This may be overridden with an explicit <option>-n</option> - with some other numeric value on the - command line. Note that this option is - only supported for the + with some other numeric value while + <option>-nall</option> will disable this cap. + Note that this option is only supported for the <citerefentry project='man-pages'><refentrytitle>less</refentrytitle><manvolnum>1</manvolnum></citerefentry> pager.</para></listitem> </varlistentry> @@ -204,9 +204,10 @@ journal events and limit the number of events shown. If <option>--follow</option> is used, - this option is implied. The argument, - a positive integer, is optional, and - defaults to 10. </para></listitem> + this option is implied. The argument is + a positive integer or <literal>all</literal> + to disable line limiting. The default value is + 10 if no argument is given.</para></listitem> </varlistentry> <varlistentry> diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c index f3680d1ce2..d00a815ba9 100644 --- a/src/journal/journalctl.c +++ b/src/journal/journalctl.c @@ -68,7 +68,7 @@ static bool arg_follow = false; static bool arg_full = true; static bool arg_all = false; static bool arg_no_pager = false; -static int arg_lines = -1; +static int arg_lines = -2; static bool arg_no_tail = false; static bool arg_quiet = false; static bool arg_merge = false; @@ -327,7 +327,7 @@ static int parse_argv(int argc, char *argv[]) { case 'e': arg_pager_end = true; - if (arg_lines < 0) + if (arg_lines < -1) arg_lines = 1000; break; @@ -366,29 +366,33 @@ static int parse_argv(int argc, char *argv[]) { case 'n': if (optarg) { - r = safe_atoi(optarg, &arg_lines); - if (r < 0 || arg_lines < 0) { - log_error("Failed to parse lines '%s'", optarg); - return -EINVAL; + if (streq(optarg, "all")) + arg_lines = -1; + else { + r = safe_atoi(optarg, &arg_lines); + if (r < 0 || arg_lines < 0) { + log_error("Failed to parse lines '%s'", optarg); + return -EINVAL; + } } } else { - int n; + arg_lines = 10; /* Hmm, no argument? Maybe the next * word on the command line is * supposed to be the argument? Let's * see if there is one, and is - * parsable as a positive - * integer... */ - - if (optind < argc && - safe_atoi(argv[optind], &n) >= 0 && - n >= 0) { - - arg_lines = n; - optind++; - } else - arg_lines = 10; + * parsable. */ + if (optind < argc) { + int n; + if (streq(argv[optind], "all")) { + arg_lines = -1; + optind++; + } else if (safe_atoi(argv[optind], &n) >= 0 && n >= 0) { + arg_lines = n; + optind++; + } + } } break; @@ -642,7 +646,7 @@ static int parse_argv(int argc, char *argv[]) { assert_not_reached("Unhandled option"); } - if (arg_follow && !arg_no_tail && arg_lines < 0) + if (arg_follow && !arg_no_tail && arg_lines < -1) arg_lines = 10; if (!!arg_directory + !!arg_file + !!arg_machine > 1) { |