diff options
author | Rob Landley <rob@landley.net> | 2018-03-10 20:22:52 -0600 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2018-03-10 20:22:52 -0600 |
commit | 9d84dc3564a6bc2e4a9ac83c0c84e7e295b420a4 (patch) | |
tree | 4a5a5ff647e5c21e3991dc446221204e02f32403 /lib | |
parent | a36cf940366ed0ad303fa25044e9964617e73c22 (diff) | |
download | toybox-9d84dc3564a6bc2e4a9ac83c0c84e7e295b420a4.tar.gz |
Add a way for commands to distinguish "ps -ax" from "ps ax".
Diffstat (limited to 'lib')
-rw-r--r-- | lib/args.c | 9 | ||||
-rw-r--r-- | lib/lib.h | 1 |
2 files changed, 5 insertions, 5 deletions
@@ -76,8 +76,7 @@ // <0 die if less than # leftover arguments (default 0) // >9 die if > # leftover arguments (default MAX_INT) // ? Allow unknown arguments (pass them through to command). -// & first argument has imaginary dash (ala tar/ps) -// If given twice, all arguments have imaginary dash +// & first arg has imaginary dash (ala tar/ps/ar) which sets FLAGS_NODASH // // At the end: [groups] of previously seen options // - Only one in group (switch off) [-abc] means -ab=-b, -ba=-a, -abc=-c @@ -120,7 +119,7 @@ struct longopts { // State during argument parsing. struct getoptflagstate { - int argc, minargs, maxargs, nodash; + int argc, minargs, maxargs; char *arg; struct opts *opts; struct longopts *longopts; @@ -244,7 +243,7 @@ void parse_optflaglist(struct getoptflagstate *gof) else if (*options == '<') gof->minargs=*(++options)-'0'; else if (*options == '>') gof->maxargs=*(++options)-'0'; else if (*options == '?') gof->noerror++; - else if (*options == '&') gof->nodash++; + else if (*options == '&') toys.optflags |= FLAGS_NODASH; else break; options++; } @@ -444,7 +443,7 @@ void get_optflags(void) // Handle things that don't start with a dash. } else { - if (gof.nodash && (gof.nodash>1 || gof.argc == 1)) gof.nodash_now = 1; + if ((toys.optflags & FLAGS_NODASH) && gof.argc == 1) gof.nodash_now = 1; else goto notflag; } @@ -53,6 +53,7 @@ struct num_cache *add_num_cache(struct num_cache **cache, long long num, void *data, int len); // args.c +#define FLAGS_NODASH (1LL<<63) void get_optflags(void); // dirtree.c |