summaryrefslogtreecommitdiff
path: root/lib/args.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2013-09-06 12:18:46 -0500
committerRob Landley <rob@landley.net>2013-09-06 12:18:46 -0500
commitc8a49971cbec622573980c276c860aa43ba43b36 (patch)
tree60188786c1d14d85b94e5e1790631e3440d6c869 /lib/args.c
parent46e8e1dcb3f616a675bf33c83531ee05a4dd8374 (diff)
downloadtoybox-c8a49971cbec622573980c276c860aa43ba43b36.tar.gz
toybox-c8a49971cbec622573980c276c860aa43ba43b36.tar.bz2
toybox-c8a49971cbec622573980c276c860aa43ba43b36.zip
Make [-abc] exclude logic clear argument slots when disabling options.
Diffstat (limited to 'lib/args.c')
-rw-r--r--lib/args.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/args.c b/lib/args.c
index 73063d6..f6bc482 100644
--- a/lib/args.c
+++ b/lib/args.c
@@ -124,7 +124,14 @@ static int gotflag(struct getoptflagstate *gof, struct opts *opt)
}
// Set flags
- toys.optflags &= ~opt->dex[0];
+ if (toys.optflags & opt->dex[0]) {
+ struct opts *clr;
+ unsigned i = 1;
+
+ for (clr=gof->opts, i=1; ; clr = clr->next, i<<=1)
+ if (clr->arg && (i & toys.optflags)) clr->arg = 0;
+ toys.optflags &= ~opt->dex[0];
+ }
toys.optflags |= opt->dex[1];
gof->excludes |= opt->dex[2];
if (opt->flags&2) gof->stopearly=2;