--- /dev/null
+#define _POSIX_C_SOURCE 200809L
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+/* Public domain by Nathan Wagner */
+
+extern char **environ;
+
+static void printenv() {
+ char **env;
+ for (env = environ; *env; env++) {
+ printf("%s\n", *env);
+ }
+}
+
+static void clearenv() {
+ char var[1024]; /* TODO how long can the name be ? */
+ char *s;
+ int i;
+
+ while (*environ) {
+ i = 0;
+ s = *environ;
+ while (*s && *s != '=') {
+ var[i++] = *s++;
+ }
+ var[i] = 0;
+ unsetenv(var);
+ }
+}
+
+int main(int ac, char *av[]) {
+ int arg;
+ arg = 1;
+ if (arg < ac && !strcmp(av[arg], "-i")) {
+ clearenv();
+ arg++;
+ }
+ while (arg < ac) {
+ char *eq;
+ eq = strchr(av[arg], '=');
+ if (eq) {
+ *eq = 0;
+ setenv(av[arg], eq+1, 1);
+ *eq = '=';
+ } else {
+ break;
+ }
+ arg++;
+ }
+
+ if (arg >= ac) {
+ printenv();
+ return 0;
+ }
+
+ execvp(av[arg], &av[arg]);
+ return 0;
+}