From e6ac7c1cf4aa18ef01cb29d00b4012f005e2f123 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Thu, 25 May 2017 13:00:00 -0500 Subject: Teach env that - as first argument means -i for some reason. (Posix!) --- toys/posix/env.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'toys/posix/env.c') diff --git a/toys/posix/env.c b/toys/posix/env.c index c2fc5cf3..ddb2f598 100644 --- a/toys/posix/env.c +++ b/toys/posix/env.c @@ -29,7 +29,13 @@ extern char **environ; void env_main(void) { - char **ev; + char **ev = toys.optargs; + + // If first nonoption argument is "-" treat it as -i + if (*ev && **ev == '-' && !(*ev)[1]) { + toys.optflags |= FLAG_i; + ev++; + } if (toys.optflags & FLAG_i) clearenv(); while (TT.u) { @@ -37,7 +43,7 @@ void env_main(void) TT.u = TT.u->next; } - for (ev = toys.optargs; *ev; ev++) { + for (; *ev; ev++) { char *name = *ev, *val = strchr(name, '='); if (val) { -- cgit v1.2.3