changeset 1677:49c851da3658

Cleanup pass on env, removing exec_optargs().
author Rob Landley <rob@landley.net>
date Sat, 07 Feb 2015 16:23:03 -0600
parents cbb1aca81eca
children 4a6a53da1c53
files toys/posix/env.c
diffstat 1 files changed, 4 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/toys/posix/env.c	Sat Feb 07 16:17:44 2015 -0600
+++ b/toys/posix/env.c	Sat Feb 07 16:23:03 2015 -0600
@@ -24,28 +24,17 @@
 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;
+    char *env = strtok(*ev, del), *val = 0;
 
-    env = strtok(*ev, del);
-
-    if (env) val = strtok(NULL, del);
-
+    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);
 }