diff options
| author | Eric Andersen <andersen@codepoet.org> | 2001-03-29 22:48:33 +0000 |
|---|---|---|
| committer | Eric Andersen <andersen@codepoet.org> | 2001-03-29 22:48:33 +0000 |
| commit | 84e229cfbe00d27ce81dad66c982bec0d50cdfd7 (patch) | |
| tree | 3b13416dae3293c97fdb0a66309bfa79e40cafcd /shell | |
| parent | e5c24dfd010732ab6b80a96ad2a5414499c496c0 (diff) | |
| download | busybox-w32-84e229cfbe00d27ce81dad66c982bec0d50cdfd7.tar.gz busybox-w32-84e229cfbe00d27ce81dad66c982bec0d50cdfd7.tar.bz2 busybox-w32-84e229cfbe00d27ce81dad66c982bec0d50cdfd7.zip | |
Add in a new standalone env applet for fixing up app's environments
-Erik
Diffstat (limited to 'shell')
| -rw-r--r-- | shell/lash.c | 21 |
1 files changed, 5 insertions, 16 deletions
diff --git a/shell/lash.c b/shell/lash.c index 22c56d444..28015cbb3 100644 --- a/shell/lash.c +++ b/shell/lash.c | |||
| @@ -143,7 +143,6 @@ struct close_me { | |||
| 143 | 143 | ||
| 144 | /* function prototypes for builtins */ | 144 | /* function prototypes for builtins */ |
| 145 | static int builtin_cd(struct child_prog *cmd); | 145 | static int builtin_cd(struct child_prog *cmd); |
| 146 | static int builtin_env(struct child_prog *dummy); | ||
| 147 | static int builtin_exec(struct child_prog *cmd); | 146 | static int builtin_exec(struct child_prog *cmd); |
| 148 | static int builtin_exit(struct child_prog *cmd); | 147 | static int builtin_exit(struct child_prog *cmd); |
| 149 | static int builtin_fg_bg(struct child_prog *cmd); | 148 | static int builtin_fg_bg(struct child_prog *cmd); |
| @@ -203,7 +202,6 @@ static struct built_in_command bltins[] = { | |||
| 203 | /* Table of forking built-in functions (things that fork cannot change global | 202 | /* Table of forking built-in functions (things that fork cannot change global |
| 204 | * variables in the parent process, such as the current working directory) */ | 203 | * variables in the parent process, such as the current working directory) */ |
| 205 | static struct built_in_command bltins_forking[] = { | 204 | static struct built_in_command bltins_forking[] = { |
| 206 | {"env", "Print all environment variables", builtin_env}, | ||
| 207 | {"pwd", "Print current directory", builtin_pwd}, | 205 | {"pwd", "Print current directory", builtin_pwd}, |
| 208 | {"help", "List shell built-in commands", builtin_help}, | 206 | {"help", "List shell built-in commands", builtin_help}, |
| 209 | {NULL, NULL, NULL} | 207 | {NULL, NULL, NULL} |
| @@ -256,14 +254,13 @@ static inline void debug_printf(const char *format, ...) { } | |||
| 256 | builtin previous use notes | 254 | builtin previous use notes |
| 257 | ------ ----------------- --------- | 255 | ------ ----------------- --------- |
| 258 | cd cmd->progs[0] | 256 | cd cmd->progs[0] |
| 259 | env 0 | ||
| 260 | exec cmd->progs[0] squashed bug: didn't look for applets or forking builtins | 257 | exec cmd->progs[0] squashed bug: didn't look for applets or forking builtins |
| 261 | exit cmd->progs[0] | 258 | exit cmd->progs[0] |
| 262 | fg_bg cmd->progs[0], job_list->head, job_list->fg | 259 | fg_bg cmd->progs[0], job_list->head, job_list->fg |
| 263 | help 0 | 260 | help 0 |
| 264 | jobs job_list->head | 261 | jobs job_list->head |
| 265 | pwd 0 | 262 | pwd 0 |
| 266 | export cmd->progs[0] passes cmd, job_list to builtin_env(), which ignores them | 263 | export cmd->progs[0] |
| 267 | source cmd->progs[0] | 264 | source cmd->progs[0] |
| 268 | unset cmd->progs[0] | 265 | unset cmd->progs[0] |
| 269 | read cmd->progs[0] | 266 | read cmd->progs[0] |
| @@ -302,17 +299,6 @@ static int builtin_cd(struct child_prog *child) | |||
| 302 | return EXIT_SUCCESS; | 299 | return EXIT_SUCCESS; |
| 303 | } | 300 | } |
| 304 | 301 | ||
| 305 | /* built-in 'env' handler */ | ||
| 306 | static int builtin_env(struct child_prog *dummy) | ||
| 307 | { | ||
| 308 | char **e; | ||
| 309 | |||
| 310 | for (e = environ; *e; e++) { | ||
| 311 | printf( "%s\n", *e); | ||
| 312 | } | ||
| 313 | return (0); | ||
| 314 | } | ||
| 315 | |||
| 316 | /* built-in 'exec' handler */ | 302 | /* built-in 'exec' handler */ |
| 317 | static int builtin_exec(struct child_prog *child) | 303 | static int builtin_exec(struct child_prog *child) |
| 318 | { | 304 | { |
| @@ -436,7 +422,10 @@ static int builtin_export(struct child_prog *child) | |||
| 436 | char *v = child->argv[1]; | 422 | char *v = child->argv[1]; |
| 437 | 423 | ||
| 438 | if (v == NULL) { | 424 | if (v == NULL) { |
| 439 | return (builtin_env(child)); | 425 | char **e; |
| 426 | for (e = environ; *e; e++) { | ||
| 427 | printf( "%s\n", *e); | ||
| 428 | } | ||
| 440 | } | 429 | } |
| 441 | res = putenv(v); | 430 | res = putenv(v); |
| 442 | if (res) | 431 | if (res) |
