Don't fork for the . (source) command so that environment settings are
authorMatt Kraai <kraai@debian.org>
Wed, 13 Sep 2000 03:43:36 +0000 (03:43 -0000)
committerMatt Kraai <kraai@debian.org>
Wed, 13 Sep 2000 03:43:36 +0000 (03:43 -0000)
preserved.

lash.c
sh.c
shell/lash.c

diff --git a/lash.c b/lash.c
index 9f67f1c9170ee34f1f7ff8b127ba96a378a3f82e..cd27e468bd7dc5b99633b02251c998088dd27369 100644 (file)
--- a/lash.c
+++ b/lash.c
@@ -145,6 +145,7 @@ static struct builtInCommand bltins[] = {
        {"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[] = {
 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 @@ static int builtin_source(struct job *cmd, struct jobSet *junk)
 
        /* Now run the file */
        status = busy_loop(input);
+       fclose(input);
        return (status);
 }
 
diff --git a/sh.c b/sh.c
index 9f67f1c9170ee34f1f7ff8b127ba96a378a3f82e..cd27e468bd7dc5b99633b02251c998088dd27369 100644 (file)
--- a/sh.c
+++ b/sh.c
@@ -145,6 +145,7 @@ static struct builtInCommand bltins[] = {
        {"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[] = {
 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 @@ static int builtin_source(struct job *cmd, struct jobSet *junk)
 
        /* Now run the file */
        status = busy_loop(input);
+       fclose(input);
        return (status);
 }
 
index 9f67f1c9170ee34f1f7ff8b127ba96a378a3f82e..cd27e468bd7dc5b99633b02251c998088dd27369 100644 (file)
@@ -145,6 +145,7 @@ static struct builtInCommand bltins[] = {
        {"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[] = {
 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 @@ static int builtin_source(struct job *cmd, struct jobSet *junk)
 
        /* Now run the file */
        status = busy_loop(input);
+       fclose(input);
        return (status);
 }