diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-09-30 23:50:48 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-09-30 23:50:48 +0000 |
commit | 96e1b38586e80a0f014038bf4fdf4689c668fbd6 (patch) | |
tree | d7f6a7866700601598cfcc006b7dcb6cb4a7c07e /shell/hush.c | |
parent | deabacdf91c6d1c3cfcdb4cd06780807193de81d (diff) | |
download | busybox-w32-96e1b38586e80a0f014038bf4fdf4689c668fbd6.tar.gz busybox-w32-96e1b38586e80a0f014038bf4fdf4689c668fbd6.tar.bz2 busybox-w32-96e1b38586e80a0f014038bf4fdf4689c668fbd6.zip |
introduce and use close_on_exec_on(fd). -50 bytes.
Diffstat (limited to 'shell/hush.c')
-rw-r--r-- | shell/hush.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/shell/hush.c b/shell/hush.c index 5f9f2c5c1..9c705568d 100644 --- a/shell/hush.c +++ b/shell/hush.c | |||
@@ -760,9 +760,11 @@ static int builtin_eval(char **argv) | |||
760 | static int builtin_cd(char **argv) | 760 | static int builtin_cd(char **argv) |
761 | { | 761 | { |
762 | const char *newdir; | 762 | const char *newdir; |
763 | if (argv[1] == NULL) | 763 | if (argv[1] == NULL) { |
764 | // bash does nothing (exitcode 0) if HOME is ""; if it's unset, | ||
765 | // bash says "bash: cd: HOME not set" and does nothing (exitcode 1) | ||
764 | newdir = getenv("HOME") ? : "/"; | 766 | newdir = getenv("HOME") ? : "/"; |
765 | else | 767 | } else |
766 | newdir = argv[1]; | 768 | newdir = argv[1]; |
767 | if (chdir(newdir)) { | 769 | if (chdir(newdir)) { |
768 | printf("cd: %s: %s\n", newdir, strerror(errno)); | 770 | printf("cd: %s: %s\n", newdir, strerror(errno)); |
@@ -3629,7 +3631,7 @@ static void setup_job_control(void) | |||
3629 | 3631 | ||
3630 | saved_task_pgrp = shell_pgrp = getpgrp(); | 3632 | saved_task_pgrp = shell_pgrp = getpgrp(); |
3631 | debug_printf_jobs("saved_task_pgrp=%d\n", saved_task_pgrp); | 3633 | debug_printf_jobs("saved_task_pgrp=%d\n", saved_task_pgrp); |
3632 | fcntl(interactive_fd, F_SETFD, FD_CLOEXEC); | 3634 | close_on_exec_on(interactive_fd); |
3633 | 3635 | ||
3634 | /* If we were ran as 'hush &', | 3636 | /* If we were ran as 'hush &', |
3635 | * sleep until we are in the foreground. */ | 3637 | * sleep until we are in the foreground. */ |