+ int len = e - p;
+#ifndef HAVE_UNSETENV
+#ifdef HAVE_MINGW
+ // Windows requires putenv("FOO=") to unset %FOO%
+ len++;
+#endif
+#endif
+ char var[len + 1];
+ memcpy(var, p, len);
+ var[len] = 0;
+#ifdef HAVE_UNSETENV
+ unsetenv(var);
+#else
+ // We must keep what we putenv() around in memory.
+ // To do this without memory leaks, keep things in a list and reuse if possible.
+ static list_t list = {};
+
+ for(list_node_t *node = list.head; node; node = node->next) {
+ char *data = node->data;
+
+ if(!strcmp(data, var)) {
+ putenv(data);
+ return;
+ }
+ }
+
+ char *data = xstrdup(var);
+ list_insert_tail(&list, data);
+ putenv(data);
+#endif
+}
+#else
+void putenv(const char *p) {}
+void unputenv(const char *p) {}
+#endif
+
+bool execute_script(const char *name, char **envp) {
+#ifdef HAVE_SYSTEM
+ char *scriptname;
+ char *interpreter = NULL;
+ config_t *cfg_interpreter;
+ int status, len, i;
+
+ cfg_interpreter = lookup_config(config_tree, "ScriptsInterpreter");