X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fjournal%2Fjournalctl.c;h=6b580d430749d423aea39818924018cbad5a32ad;hb=e2c8b07dcb50c2adf64cdfb22e4a496fc76576fb;hp=e2600542fc74caf5b2dc4dab0062f485ff713f63;hpb=a1a03e3075316e2376176fc54c74e071adc9d71a;p=elogind.git diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c index e2600542f..6b580d430 100644 --- a/src/journal/journalctl.c +++ b/src/journal/journalctl.c @@ -32,6 +32,8 @@ #include #include #include +#include +#include #include @@ -85,7 +87,7 @@ static int help(void) { " --no-pager Do not pipe output into a pager\n" " -a --all Show all fields, including long and unprintable\n" " -f --follow Follow journal\n" - " -n --lines=INTEGER Journal entries to show\n" + " -n --lines[=INTEGER] Number of journal entries to show\n" " --no-tail Show all lines, even in follow mode\n" " -o --output=STRING Change journal output mode (short, short-monotonic,\n" " verbose, export, json, json-pretty, cat)\n" @@ -131,7 +133,7 @@ static int parse_argv(int argc, char *argv[]) { { "follow", no_argument, NULL, 'f' }, { "output", required_argument, NULL, 'o' }, { "all", no_argument, NULL, 'a' }, - { "lines", required_argument, NULL, 'n' }, + { "lines", optional_argument, NULL, 'n' }, { "no-tail", no_argument, NULL, ARG_NO_TAIL }, { "new-id128", no_argument, NULL, ARG_NEW_ID128 }, { "quiet", no_argument, NULL, 'q' }, @@ -153,7 +155,7 @@ static int parse_argv(int argc, char *argv[]) { assert(argc >= 0); assert(argv); - while ((c = getopt_long(argc, argv, "hfo:an:qmbD:p:", options, NULL)) >= 0) { + while ((c = getopt_long(argc, argv, "hfo:an::qmbD:p:", options, NULL)) >= 0) { switch (c) { @@ -176,7 +178,7 @@ static int parse_argv(int argc, char *argv[]) { break; case 'o': - arg_output = output_mode_from_string(optarg); + arg_output = output_mode_from_string(optarg); if (arg_output < 0) { log_error("Unknown output '%s'.", optarg); return -EINVAL; @@ -189,11 +191,15 @@ static int parse_argv(int argc, char *argv[]) { break; case 'n': - r = safe_atoi(optarg, &arg_lines); - if (r < 0 || arg_lines < 0) { - log_error("Failed to parse lines '%s'", optarg); - return -EINVAL; - } + if (optarg) { + r = safe_atoi(optarg, &arg_lines); + if (r < 0 || arg_lines < 0) { + log_error("Failed to parse lines '%s'", optarg); + return -EINVAL; + } + } else + arg_lines = 10; + break; case ARG_NO_TAIL: @@ -634,8 +640,13 @@ static int setup_keys(void) { fprintf(stderr, "\nThe keys have been generated for host " SD_ID128_FORMAT_STR ".\n", SD_ID128_FORMAT_VAL(machine)); #ifdef HAVE_QRENCODE - fprintf(stderr, "\nTo transfer the verification key to your phone please scan the QR code below:\n\n"); - print_qr_code(stderr, seed, seed_size, n, arg_interval, hn, machine); + /* If this is not an UTF-8 system don't print any QR codes */ + setlocale(LC_CTYPE, ""); + + if (streq_ptr(nl_langinfo(CODESET), "UTF-8")) { + fputs("\nTo transfer the verification key to your phone please scan the QR code below:\n\n", stderr); + print_qr_code(stderr, seed, seed_size, n, arg_interval, hn, machine); + } #endif free(hn); }