tree-wide: add a helper to parse boolean optarg
This nicely covers the case when optarg is optional. The same parser can be used when the option string passed to getopt_long() requires a parameter and when it doesn't. The error messages are made consistent. Also fixes a log error c&p in --crash-reboot message.
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
#include "mount-util.h"
|
||||
#include "mountpoint-util.h"
|
||||
#include "pager.h"
|
||||
#include "parse-argument.h"
|
||||
#include "parse-util.h"
|
||||
#include "path-util.h"
|
||||
#include "pretty-print.h"
|
||||
@@ -265,11 +266,9 @@ static int parse_argv(int argc, char *argv[]) {
|
||||
}
|
||||
|
||||
case ARG_FSCK:
|
||||
r = parse_boolean(optarg);
|
||||
r = parse_boolean_argument("--fsck=", optarg, &arg_fsck);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to parse --fsck= argument: %s", optarg);
|
||||
|
||||
arg_fsck = r;
|
||||
return r;
|
||||
break;
|
||||
|
||||
case ARG_DESCRIPTION:
|
||||
|
||||
Reference in New Issue
Block a user