aboutsummaryrefslogtreecommitdiff
path: root/sh.c
diff options
context:
space:
mode:
Diffstat (limited to 'sh.c')
-rw-r--r--sh.c21
1 files changed, 5 insertions, 16 deletions
diff --git a/sh.c b/sh.c
index 22c56d444..28015cbb3 100644
--- a/sh.c
+++ b/sh.c
@@ -143,7 +143,6 @@ struct close_me {
143 143
144/* function prototypes for builtins */ 144/* function prototypes for builtins */
145static int builtin_cd(struct child_prog *cmd); 145static int builtin_cd(struct child_prog *cmd);
146static int builtin_env(struct child_prog *dummy);
147static int builtin_exec(struct child_prog *cmd); 146static int builtin_exec(struct child_prog *cmd);
148static int builtin_exit(struct child_prog *cmd); 147static int builtin_exit(struct child_prog *cmd);
149static int builtin_fg_bg(struct child_prog *cmd); 148static 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) */
205static struct built_in_command bltins_forking[] = { 204static 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, ...) { }
256builtin previous use notes 254builtin previous use notes
257------ ----------------- --------- 255------ ----------------- ---------
258cd cmd->progs[0] 256cd cmd->progs[0]
259env 0
260exec cmd->progs[0] squashed bug: didn't look for applets or forking builtins 257exec cmd->progs[0] squashed bug: didn't look for applets or forking builtins
261exit cmd->progs[0] 258exit cmd->progs[0]
262fg_bg cmd->progs[0], job_list->head, job_list->fg 259fg_bg cmd->progs[0], job_list->head, job_list->fg
263help 0 260help 0
264jobs job_list->head 261jobs job_list->head
265pwd 0 262pwd 0
266export cmd->progs[0] passes cmd, job_list to builtin_env(), which ignores them 263export cmd->progs[0]
267source cmd->progs[0] 264source cmd->progs[0]
268unset cmd->progs[0] 265unset cmd->progs[0]
269read cmd->progs[0] 266read 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 */
306static 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 */
317static int builtin_exec(struct child_prog *child) 303static 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)