X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fcore%2Fshutdown.c;h=48ed7fa1c3a0eb25d2e6d718137815125fdf910a;hb=609c3029076da1ba423673161e5d0fc82ccca6b6;hp=20cf526ba2716b34fe1a2fc9bde05a396b160502;hpb=d89b5fed9ea5d9ec293585cb85bb27b56ea6ac9c;p=elogind.git diff --git a/src/core/shutdown.c b/src/core/shutdown.c index 20cf526ba..48ed7fa1c 100644 --- a/src/core/shutdown.c +++ b/src/core/shutdown.c @@ -75,7 +75,9 @@ static int parse_argv(int argc, char *argv[]) { assert(argc >= 1); assert(argv); - while ((c = getopt_long(argc, argv, "", options, NULL)) >= 0) + /* "-" prevents getopt from permuting argv[] and moving the verb away + * from argv[1]. Our interface to initrd promises it'll be there. */ + while ((c = getopt_long(argc, argv, "-", options, NULL)) >= 0) switch (c) { case ARG_LOG_LEVEL: @@ -113,6 +115,13 @@ static int parse_argv(int argc, char *argv[]) { break; + case '\001': + if (!arg_verb) + arg_verb = optarg; + else + log_error("Excess arguments, ignoring"); + break; + case '?': return -EINVAL; @@ -120,15 +129,11 @@ static int parse_argv(int argc, char *argv[]) { assert_not_reached("Unhandled option code."); } - if (optind >= argc) { + if (!arg_verb) { log_error("Verb argument missing."); return -EINVAL; } - arg_verb = argv[optind]; - - if (optind + 1 < argc) - log_error("Excess arguments, ignoring"); return 0; } @@ -165,7 +170,7 @@ int main(int argc, char *argv[]) { goto error; /* journald will die if not gone yet. The log target defaults - * to console, but may have been changed by commandline options. */ + * to console, but may have been changed by command line options. */ log_close_console(); /* force reopen of /dev/console */ log_open();