summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-02-12 00:31:13 +0100
committerLennart Poettering <lennart@poettering.net>2013-02-12 00:31:13 +0100
commit96088db02b2802049f1edbd44d5f8c2ea838f3f2 (patch)
tree8877df2e03f4ba9738108aadf4d96f3f16084f62 /src
parent8b55b8c4e7fce5e05dcfd783a37fb843d1bf1868 (diff)
journalctl: allow both "-n 55" and "-n55" on the command line, as equivalent syntaxes
https://bugs.freedesktop.org/show_bug.cgi?id=60596
Diffstat (limited to 'src')
-rw-r--r--src/journal/journalctl.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
index 0ec2f331db..0afeef932e 100644
--- a/src/journal/journalctl.c
+++ b/src/journal/journalctl.c
@@ -244,8 +244,25 @@ static int parse_argv(int argc, char *argv[]) {
log_error("Failed to parse lines '%s'", optarg);
return -EINVAL;
}
- } else
- arg_lines = 10;
+ } else {
+ int n;
+
+ /* 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;
+ }
break;