Don't fork for the . (source) command so that environment settings are
preserved.
diff --git a/sh.c b/sh.c
index 9f67f1c..cd27e46 100644
--- a/sh.c
+++ b/sh.c
@@ -145,6 +145,7 @@
{"export", "Set environment variable", builtin_export},
{"unset", "Unset environment variable", builtin_unset},
{"read", "Input environment variable", builtin_read},
+ {".", "Source-in and run commands in a file", builtin_source},
#ifdef BB_FEATURE_SH_IF_EXPRESSIONS
{"if", NULL, builtin_if},
{"then", NULL, builtin_then},
@@ -159,7 +160,6 @@
static struct builtInCommand bltins_forking[] = {
{"env", "Print all environment variables", builtin_env},
{"pwd", "Print current directory", builtin_pwd},
- {".", "Source-in and run commands in a file", builtin_source},
{"help", "List shell built-in commands", builtin_help},
{NULL, NULL, NULL}
};
@@ -500,6 +500,7 @@
/* Now run the file */
status = busy_loop(input);
+ fclose(input);
return (status);
}