aboutsummaryrefslogtreecommitdiff
path: root/toys/posix
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2017-05-25 13:00:00 -0500
committerRob Landley <rob@landley.net>2017-05-25 13:00:00 -0500
commite6ac7c1cf4aa18ef01cb29d00b4012f005e2f123 (patch)
tree0ea85d2d08e344139db901b768af4fd27c44cd23 /toys/posix
parent12f0744f340746b3a1c1accfdf993d6548f33e56 (diff)
downloadtoybox-e6ac7c1cf4aa18ef01cb29d00b4012f005e2f123.tar.gz
Teach env that - as first argument means -i for some reason. (Posix!)
Diffstat (limited to 'toys/posix')
-rw-r--r--toys/posix/env.c10
1 files changed, 8 insertions, 2 deletions
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) {