mirror of
https://github.com/koverstreet/bcachefs-tools.git
synced 2025-12-10 00:00:24 +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;
|
return NULL;
|
||||||
|
|
||||||
char *optstr = strdup(argv[optind] + 2);
|
char *optstr = strdup(argv[optind] + 2);
|
||||||
optarg = argv[optind + 1];
|
optarg = NULL;
|
||||||
|
|
||||||
char *eq = strchr(optstr, '=');
|
char *eq = strchr(optstr, '=');
|
||||||
if (eq) {
|
if (eq) {
|
||||||
@ -744,10 +744,6 @@ const struct bch_option *bch2_cmdline_opt_parse(int argc, char *argv[],
|
|||||||
optarg = eq + 1;
|
optarg = eq + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!optarg)
|
|
||||||
optarg = "1";
|
|
||||||
|
|
||||||
|
|
||||||
int optid = bch2_opt_lookup(optstr);
|
int optid = bch2_opt_lookup(optstr);
|
||||||
if (optid < 0)
|
if (optid < 0)
|
||||||
goto noopt;
|
goto noopt;
|
||||||
@ -758,11 +754,11 @@ const struct bch_option *bch2_cmdline_opt_parse(int argc, char *argv[],
|
|||||||
|
|
||||||
optind++;
|
optind++;
|
||||||
|
|
||||||
if (opt->type != BCH_OPT_BOOL) {
|
if (!optarg) {
|
||||||
if (optarg == argv[optind])
|
if (opt->type != BCH_OPT_BOOL)
|
||||||
optind++;
|
optarg = argv[optind++];
|
||||||
} else {
|
else
|
||||||
optarg = NULL;
|
optarg = "1";
|
||||||
}
|
}
|
||||||
|
|
||||||
return opt;
|
return opt;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user