mirror of
https://github.com/koverstreet/bcachefs-tools.git
synced 2025-12-08 00:00:12 +03:00
fix bool opt parsing
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
69f9e726df
commit
36de1e40a2
@ -736,7 +736,7 @@ const struct bch_option *bch2_cmdline_opt_parse(int argc, char *argv[],
|
||||
return NULL;
|
||||
|
||||
char *optstr = strdup(argv[optind] + 2);
|
||||
optarg = argv[optind + 1];
|
||||
optarg = NULL;
|
||||
|
||||
char *eq = strchr(optstr, '=');
|
||||
if (eq) {
|
||||
@ -744,10 +744,6 @@ const struct bch_option *bch2_cmdline_opt_parse(int argc, char *argv[],
|
||||
optarg = eq + 1;
|
||||
}
|
||||
|
||||
if (!optarg)
|
||||
optarg = "1";
|
||||
|
||||
|
||||
int optid = bch2_opt_lookup(optstr);
|
||||
if (optid < 0)
|
||||
goto noopt;
|
||||
@ -758,11 +754,11 @@ const struct bch_option *bch2_cmdline_opt_parse(int argc, char *argv[],
|
||||
|
||||
optind++;
|
||||
|
||||
if (opt->type != BCH_OPT_BOOL) {
|
||||
if (optarg == argv[optind])
|
||||
optind++;
|
||||
} else {
|
||||
optarg = NULL;
|
||||
if (!optarg) {
|
||||
if (opt->type != BCH_OPT_BOOL)
|
||||
optarg = argv[optind++];
|
||||
else
|
||||
optarg = "1";
|
||||
}
|
||||
|
||||
return opt;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user