diff options
author | Rob Landley <rob@landley.net> | 2017-06-05 21:22:02 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2017-06-05 21:22:02 -0500 |
commit | ab33097058b05a173113832fcca6b8d6c3b6143d (patch) | |
tree | b4f3a2aee03982b059d0cdf5d674126e09328e15 /lib | |
parent | 32550751997db5b15baca56e72c54ed8ade53bd6 (diff) | |
download | toybox-ab33097058b05a173113832fcca6b8d6c3b6143d.tar.gz |
Have help_exit() give a brief "See %s --help" message instead of the
full help text, and put it back in the args constraint failures.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/args.c | 22 | ||||
-rw-r--r-- | lib/lib.c | 3 |
2 files changed, 13 insertions, 12 deletions
@@ -136,7 +136,7 @@ static int gotflag(struct getoptflagstate *gof, struct opts *opt) // Did we recognize this option? if (!opt) { if (gof->noerror) return 1; - error_exit("Unknown option %s", gof->arg); + help_exit("Unknown option %s", gof->arg); } // Might enabling this switch off something else? @@ -163,7 +163,7 @@ static int gotflag(struct getoptflagstate *gof, struct opts *opt) if (opt == bad || !(i & toys.optflags)) continue; if (toys.optflags & bad->dex[2]) break; } - if (bad) error_exit("No '%c' with '%c'", opt->c, bad->c); + if (bad) help_exit("No '%c' with '%c'", opt->c, bad->c); } // Does this option take an argument? @@ -187,10 +187,10 @@ static int gotflag(struct getoptflagstate *gof, struct opts *opt) char *s = "Missing argument to "; struct longopts *lo; - if (opt->c != -1) error_exit("%s-%c", s, opt->c); + if (opt->c != -1) help_exit("%s-%c", s, opt->c); for (lo = gof->longopts; lo->opt != opt; lo = lo->next); - error_exit("%s--%.*s", s, lo->len, lo->str); + help_exit("%s--%.*s", s, lo->len, lo->str); } if (type == ':') *(opt->arg) = (long)arg; @@ -204,8 +204,8 @@ static int gotflag(struct getoptflagstate *gof, struct opts *opt) } else if (type == '#' || type == '-') { long l = atolx(arg); if (type == '-' && !ispunct(*arg)) l*=-1; - if (l < opt->val[0].l) error_exit("-%c < %ld", opt->c, opt->val[0].l); - if (l > opt->val[1].l) error_exit("-%c > %ld", opt->c, opt->val[1].l); + if (l < opt->val[0].l) help_exit("-%c < %ld", opt->c, opt->val[0].l); + if (l > opt->val[1].l) help_exit("-%c > %ld", opt->c, opt->val[1].l); *(opt->arg) = l; } else if (CFG_TOYBOX_FLOAT && type == '.') { @@ -213,9 +213,9 @@ static int gotflag(struct getoptflagstate *gof, struct opts *opt) *f = strtod(arg, &arg); if (opt->val[0].l != LONG_MIN && *f < opt->val[0].f) - error_exit("-%c < %lf", opt->c, (double)opt->val[0].f); + help_exit("-%c < %lf", opt->c, (double)opt->val[0].f); if (opt->val[1].l != LONG_MAX && *f > opt->val[1].f) - error_exit("-%c > %lf", opt->c, (double)opt->val[1].f); + help_exit("-%c > %lf", opt->c, (double)opt->val[1].f); } if (!gof->nodash_now) gof->arg = ""; @@ -475,10 +475,10 @@ notflag: // Sanity check if (toys.optc<gof.minargs) - error_exit("Need%s %d argument%s", letters[!!(gof.minargs-1)], + help_exit("Need%s %d argument%s", letters[!!(gof.minargs-1)], gof.minargs, letters[!(gof.minargs-1)]); if (toys.optc>gof.maxargs) - error_exit("Max %d argument%s", gof.maxargs, letters[!(gof.maxargs-1)]); + help_exit("Max %d argument%s", gof.maxargs, letters[!(gof.maxargs-1)]); if (gof.requires && !(gof.requires & toys.optflags)) { struct opts *req; char needs[32], *s = needs; @@ -487,7 +487,7 @@ notflag: if (req->flags & 1) *(s++) = req->c; *s = 0; - error_exit("Needs %s-%s", s[1] ? "one of " : "", needs); + help_exit("Needs %s-%s", s[1] ? "one of " : "", needs); } if (CFG_TOYBOX_FREE) { @@ -66,7 +66,8 @@ void help_exit(char *msg, ...) { va_list va; - if (CFG_TOYBOX_HELP) show_help(stderr); + if (CFG_TOYBOX_HELP) + fprintf(stderr, "See %s --help\n", toys.which->name); if (msg) { va_start(va, msg); |