aboutsummaryrefslogtreecommitdiff
path: root/lib/args.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2014-08-15 18:53:01 -0500
committerRob Landley <rob@landley.net>2014-08-15 18:53:01 -0500
commit845c8da42a505835c67e2dff98353a7205e555a5 (patch)
tree890a3c9cff704f94e088339af60f6403bd9a828a /lib/args.c
parent3b5b19e7bf4598536bc7ef501598c0f6e28e4e5a (diff)
downloadtoybox-845c8da42a505835c67e2dff98353a7205e555a5.tar.gz
Fix bug reported by Ashwini Sharma: [-abc] syntax to switch off a command forget
s _all_ saved command line arguments in GLOBALS(), not just for the command bein g dropped.
Diffstat (limited to 'lib/args.c')
-rw-r--r--lib/args.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/args.c b/lib/args.c
index 16eb48ad..d0b483af 100644
--- a/lib/args.c
+++ b/lib/args.c
@@ -138,15 +138,18 @@ static int gotflag(struct getoptflagstate *gof, struct opts *opt)
error_exit("Unknown option %s", gof->arg);
}
- // Set flags
+ // Might enabling this switch off something else?
if (toys.optflags & opt->dex[0]) {
struct opts *clr;
unsigned i = 1;
+ // Forget saved argument for flag we switch back off
for (clr=gof->opts, i=1; clr; clr = clr->next, i<<=1)
- if (clr->arg && (i & toys.optflags)) *clr->arg = 0;
+ if (clr->arg && (i & toys.optflags & opt->dex[0])) *clr->arg = 0;
toys.optflags &= ~opt->dex[0];
}
+
+ // Set flags
toys.optflags |= opt->dex[1];
gof->excludes |= opt->dex[2];
if (opt->flags&2) gof->stopearly=2;