aboutsummaryrefslogtreecommitdiff
path: root/toys/posix
diff options
context:
space:
mode:
Diffstat (limited to 'toys/posix')
-rw-r--r--toys/posix/env.c19
1 files changed, 4 insertions, 15 deletions
diff --git a/toys/posix/env.c b/toys/posix/env.c
index 4e819f24..f20517eb 100644
--- a/toys/posix/env.c
+++ b/toys/posix/env.c
@@ -24,28 +24,17 @@ extern char **environ;
void env_main(void)
{
char **ev;
- char **command = NULL;
char *del = "=";
if (toys.optflags) clearenv();
for (ev = toys.optargs; *ev != NULL; ev++) {
- char *env, *val = NULL;
-
- env = strtok(*ev, del);
-
- if (env) val = strtok(NULL, del);
+ char *env = strtok(*ev, del), *val = 0;
+ if (env) val = strtok(0, del);
if (val) setenv(env, val, 1);
- else {
- command = ev;
- break;
- }
+ else xexec(ev);
}
- if (!command) {
- char **ep;
- if (environ) for (ep = environ; *ep; ep++) xputs(*ep);
- } else xexec_optargs(command - toys.optargs);
-
+ if (environ) for (ev = environ; *ev; ev++) xputs(*ev);
}