diff options
author | Matt Kraai <kraai@debian.org> | 2000-09-13 03:43:36 +0000 |
---|---|---|
committer | Matt Kraai <kraai@debian.org> | 2000-09-13 03:43:36 +0000 |
commit | dd450a0dedf50067e97e4725e1303758746ddca8 (patch) | |
tree | 4d331a535dede5a9e13a01dc417d813f255e51f9 | |
parent | 322ae93a5e0b78b65831f9fd87fd456eb84d21a1 (diff) | |
download | busybox-w32-dd450a0dedf50067e97e4725e1303758746ddca8.tar.gz busybox-w32-dd450a0dedf50067e97e4725e1303758746ddca8.tar.bz2 busybox-w32-dd450a0dedf50067e97e4725e1303758746ddca8.zip |
Don't fork for the . (source) command so that environment settings are
preserved.
-rw-r--r-- | lash.c | 3 | ||||
-rw-r--r-- | sh.c | 3 | ||||
-rw-r--r-- | shell/lash.c | 3 |
3 files changed, 6 insertions, 3 deletions
@@ -145,6 +145,7 @@ static struct builtInCommand bltins[] = { | |||
145 | {"export", "Set environment variable", builtin_export}, | 145 | {"export", "Set environment variable", builtin_export}, |
146 | {"unset", "Unset environment variable", builtin_unset}, | 146 | {"unset", "Unset environment variable", builtin_unset}, |
147 | {"read", "Input environment variable", builtin_read}, | 147 | {"read", "Input environment variable", builtin_read}, |
148 | {".", "Source-in and run commands in a file", builtin_source}, | ||
148 | #ifdef BB_FEATURE_SH_IF_EXPRESSIONS | 149 | #ifdef BB_FEATURE_SH_IF_EXPRESSIONS |
149 | {"if", NULL, builtin_if}, | 150 | {"if", NULL, builtin_if}, |
150 | {"then", NULL, builtin_then}, | 151 | {"then", NULL, builtin_then}, |
@@ -159,7 +160,6 @@ static struct builtInCommand bltins[] = { | |||
159 | static struct builtInCommand bltins_forking[] = { | 160 | static struct builtInCommand bltins_forking[] = { |
160 | {"env", "Print all environment variables", builtin_env}, | 161 | {"env", "Print all environment variables", builtin_env}, |
161 | {"pwd", "Print current directory", builtin_pwd}, | 162 | {"pwd", "Print current directory", builtin_pwd}, |
162 | {".", "Source-in and run commands in a file", builtin_source}, | ||
163 | {"help", "List shell built-in commands", builtin_help}, | 163 | {"help", "List shell built-in commands", builtin_help}, |
164 | {NULL, NULL, NULL} | 164 | {NULL, NULL, NULL} |
165 | }; | 165 | }; |
@@ -500,6 +500,7 @@ static int builtin_source(struct job *cmd, struct jobSet *junk) | |||
500 | 500 | ||
501 | /* Now run the file */ | 501 | /* Now run the file */ |
502 | status = busy_loop(input); | 502 | status = busy_loop(input); |
503 | fclose(input); | ||
503 | return (status); | 504 | return (status); |
504 | } | 505 | } |
505 | 506 | ||
@@ -145,6 +145,7 @@ static struct builtInCommand bltins[] = { | |||
145 | {"export", "Set environment variable", builtin_export}, | 145 | {"export", "Set environment variable", builtin_export}, |
146 | {"unset", "Unset environment variable", builtin_unset}, | 146 | {"unset", "Unset environment variable", builtin_unset}, |
147 | {"read", "Input environment variable", builtin_read}, | 147 | {"read", "Input environment variable", builtin_read}, |
148 | {".", "Source-in and run commands in a file", builtin_source}, | ||
148 | #ifdef BB_FEATURE_SH_IF_EXPRESSIONS | 149 | #ifdef BB_FEATURE_SH_IF_EXPRESSIONS |
149 | {"if", NULL, builtin_if}, | 150 | {"if", NULL, builtin_if}, |
150 | {"then", NULL, builtin_then}, | 151 | {"then", NULL, builtin_then}, |
@@ -159,7 +160,6 @@ static struct builtInCommand bltins[] = { | |||
159 | static struct builtInCommand bltins_forking[] = { | 160 | static struct builtInCommand bltins_forking[] = { |
160 | {"env", "Print all environment variables", builtin_env}, | 161 | {"env", "Print all environment variables", builtin_env}, |
161 | {"pwd", "Print current directory", builtin_pwd}, | 162 | {"pwd", "Print current directory", builtin_pwd}, |
162 | {".", "Source-in and run commands in a file", builtin_source}, | ||
163 | {"help", "List shell built-in commands", builtin_help}, | 163 | {"help", "List shell built-in commands", builtin_help}, |
164 | {NULL, NULL, NULL} | 164 | {NULL, NULL, NULL} |
165 | }; | 165 | }; |
@@ -500,6 +500,7 @@ static int builtin_source(struct job *cmd, struct jobSet *junk) | |||
500 | 500 | ||
501 | /* Now run the file */ | 501 | /* Now run the file */ |
502 | status = busy_loop(input); | 502 | status = busy_loop(input); |
503 | fclose(input); | ||
503 | return (status); | 504 | return (status); |
504 | } | 505 | } |
505 | 506 | ||
diff --git a/shell/lash.c b/shell/lash.c index 9f67f1c91..cd27e468b 100644 --- a/shell/lash.c +++ b/shell/lash.c | |||
@@ -145,6 +145,7 @@ static struct builtInCommand bltins[] = { | |||
145 | {"export", "Set environment variable", builtin_export}, | 145 | {"export", "Set environment variable", builtin_export}, |
146 | {"unset", "Unset environment variable", builtin_unset}, | 146 | {"unset", "Unset environment variable", builtin_unset}, |
147 | {"read", "Input environment variable", builtin_read}, | 147 | {"read", "Input environment variable", builtin_read}, |
148 | {".", "Source-in and run commands in a file", builtin_source}, | ||
148 | #ifdef BB_FEATURE_SH_IF_EXPRESSIONS | 149 | #ifdef BB_FEATURE_SH_IF_EXPRESSIONS |
149 | {"if", NULL, builtin_if}, | 150 | {"if", NULL, builtin_if}, |
150 | {"then", NULL, builtin_then}, | 151 | {"then", NULL, builtin_then}, |
@@ -159,7 +160,6 @@ static struct builtInCommand bltins[] = { | |||
159 | static struct builtInCommand bltins_forking[] = { | 160 | static struct builtInCommand bltins_forking[] = { |
160 | {"env", "Print all environment variables", builtin_env}, | 161 | {"env", "Print all environment variables", builtin_env}, |
161 | {"pwd", "Print current directory", builtin_pwd}, | 162 | {"pwd", "Print current directory", builtin_pwd}, |
162 | {".", "Source-in and run commands in a file", builtin_source}, | ||
163 | {"help", "List shell built-in commands", builtin_help}, | 163 | {"help", "List shell built-in commands", builtin_help}, |
164 | {NULL, NULL, NULL} | 164 | {NULL, NULL, NULL} |
165 | }; | 165 | }; |
@@ -500,6 +500,7 @@ static int builtin_source(struct job *cmd, struct jobSet *junk) | |||
500 | 500 | ||
501 | /* Now run the file */ | 501 | /* Now run the file */ |
502 | status = busy_loop(input); | 502 | status = busy_loop(input); |
503 | fclose(input); | ||
503 | return (status); | 504 | return (status); |
504 | } | 505 | } |
505 | 506 | ||