diff options
Diffstat (limited to 'sh.c')
-rw-r--r-- | sh.c | 21 |
1 files changed, 5 insertions, 16 deletions
@@ -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) |