aboutsummaryrefslogtreecommitdiff
path: root/toys
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2019-04-20 03:05:07 -0500
committerRob Landley <rob@landley.net>2019-04-20 03:05:07 -0500
commit543b2580c78c0f6ed12630d9e63a0420d37b8348 (patch)
tree50de120e5e4dfdfabbedb046cd633ee323e7c938 /toys
parent71c3f623c6011c923788f0770ad40fe2756893a7 (diff)
downloadtoybox-543b2580c78c0f6ed12630d9e63a0420d37b8348.tar.gz
Add xunsetenv() for the error checking.
Diffstat (limited to 'toys')
-rw-r--r--toys/posix/env.c15
1 files changed, 4 insertions, 11 deletions
diff --git a/toys/posix/env.c b/toys/posix/env.c
index d1bb580d..3a251334 100644
--- a/toys/posix/env.c
+++ b/toys/posix/env.c
@@ -40,18 +40,11 @@ void env_main(void)
}
if (FLAG(i)) xclearenv();
- else for (u = TT.u; u; u = u->next)
- if (strchr(u->arg, '=')) error_msg("bad -u %s", u->arg);
- else xsetenv(u->arg, 0);
+ else for (u = TT.u; u; u = u->next) xunsetenv(u->arg);
- for (; *ev; ev++) {
- char *val = strchr(*ev, '=');
-
- if (val) {
- *(val++) = 0;
- xsetenv(*ev, val);
- } else xexec(ev);
- }
+ for (; *ev; ev++)
+ if (strchr(*ev, '=')) xsetenv(xstrdup(*ev), 0);
+ else xexec(ev);
for (ev = environ; *ev; ev++) xprintf("%s%c", *ev, '\n'*!FLAG(0));
}