aboutsummaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2012-03-23 12:12:03 +0000
committerRon Yorston <rmy@pobox.com>2012-03-23 12:12:03 +0000
commitb0f54743e36af163ae2530c381c485bb29df13dc (patch)
treecda4cfeaae6e47fe4f14c1b566092be4da9affc4 /shell
parent40514a0309939f2446f0d4ed9600cad5de396e7f (diff)
parentba88826c66411affc1da3614742b454654f7298a (diff)
downloadbusybox-w32-b0f54743e36af163ae2530c381c485bb29df13dc.tar.gz
busybox-w32-b0f54743e36af163ae2530c381c485bb29df13dc.tar.bz2
busybox-w32-b0f54743e36af163ae2530c381c485bb29df13dc.zip
Merge branch 'busybox' into merge
Conflicts: Makefile.flags
Diffstat (limited to 'shell')
-rw-r--r--shell/ash.c18
-rw-r--r--shell/cttyhack.c13
-rw-r--r--shell/shell_common.c8
3 files changed, 32 insertions, 7 deletions
diff --git a/shell/ash.c b/shell/ash.c
index a79099bc5..065678ea5 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -7794,6 +7794,12 @@ tryexec(IF_FEATURE_SH_STANDALONE(int applet_no,) char *cmd, char **argv, char **
7794 * 7794 *
7795 * That is, do not use $SHELL, user's shell, or /bin/sh; 7795 * That is, do not use $SHELL, user's shell, or /bin/sh;
7796 * just call ourselves. 7796 * just call ourselves.
7797 *
7798 * Note that bash reads ~80 chars of the file, and if it sees
7799 * a zero byte before it sees newline, it doesn't try to
7800 * interpret it, but fails with "cannot execute binary file"
7801 * message and exit code 126. For one, this prevents attempts
7802 * to interpret foreign ELF binaries as shell scripts.
7797 */ 7803 */
7798 char **ap; 7804 char **ap;
7799 char **new; 7805 char **new;
@@ -7824,9 +7830,7 @@ shellexec(char **argv, const char *path, int idx)
7824 int e; 7830 int e;
7825 char **envp; 7831 char **envp;
7826 int exerrno; 7832 int exerrno;
7827#if ENABLE_FEATURE_SH_STANDALONE 7833 int applet_no = -1; /* used only by FEATURE_SH_STANDALONE */
7828 int applet_no = -1;
7829#endif
7830 7834
7831 clearredir(/*drop:*/ 1); 7835 clearredir(/*drop:*/ 1);
7832 envp = listvars(VEXPORT, VUNSET, /*end:*/ NULL); 7836 envp = listvars(VEXPORT, VUNSET, /*end:*/ NULL);
@@ -7836,8 +7840,16 @@ shellexec(char **argv, const char *path, int idx)
7836#endif 7840#endif
7837 ) { 7841 ) {
7838 tryexec(IF_FEATURE_SH_STANDALONE(applet_no,) argv[0], argv, envp); 7842 tryexec(IF_FEATURE_SH_STANDALONE(applet_no,) argv[0], argv, envp);
7843 if (applet_no >= 0) {
7844 /* We tried execing ourself, but it didn't work.
7845 * Maybe /proc/self/exe doesn't exist?
7846 * Try $PATH search.
7847 */
7848 goto try_PATH;
7849 }
7839 e = errno; 7850 e = errno;
7840 } else { 7851 } else {
7852 try_PATH:
7841 e = ENOENT; 7853 e = ENOENT;
7842 while ((cmdname = path_advance(&path, argv[0])) != NULL) { 7854 while ((cmdname = path_advance(&path, argv[0])) != NULL) {
7843 if (--idx < 0 && pathopt == NULL) { 7855 if (--idx < 0 && pathopt == NULL) {
diff --git a/shell/cttyhack.c b/shell/cttyhack.c
index 6ff867413..f9b59c263 100644
--- a/shell/cttyhack.c
+++ b/shell/cttyhack.c
@@ -123,15 +123,22 @@ int cttyhack_main(int argc UNUSED_PARAM, char **argv)
123 * TIOCGSERIAL check, which assumes that all 123 * TIOCGSERIAL check, which assumes that all
124 * serial lines follow /dev/ttySn convention - 124 * serial lines follow /dev/ttySn convention -
125 * which is not always the case. 125 * which is not always the case.
126 * Therefore, we use this methos first: 126 * Therefore, we use this method first:
127 */ 127 */
128 int s = open_read_close("/sys/class/tty/console/active", 128 int s = open_read_close("/sys/class/tty/console/active",
129 console + 5, sizeof(console) - 5); 129 console + 5, sizeof(console) - 5);
130 if (s > 0) { 130 if (s > 0) {
131 /* found active console via sysfs (Linux 2.6.38+) 131 char *last;
132 * sysfs string looks like "ttyS0\n" so zap the newline: 132 /* Found active console via sysfs (Linux 2.6.38+).
133 * It looks like "[tty0 ]ttyS0\n" so zap the newline:
133 */ 134 */
134 console[4 + s] = '\0'; 135 console[4 + s] = '\0';
136 /* If there are multiple consoles,
137 * take the last one:
138 */
139 last = strrchr(console + 5, ' ');
140 if (last)
141 overlapping_strcpy(console + 5, last + 1);
135 break; 142 break;
136 } 143 }
137 144
diff --git a/shell/shell_common.c b/shell/shell_common.c
index 4329ca05c..0ffe21e0b 100644
--- a/shell/shell_common.c
+++ b/shell/shell_common.c
@@ -138,7 +138,13 @@ shell_builtin_read(void FAST_FUNC (*setvar)(const char *name, const char *val),
138 old_tty = tty; 138 old_tty = tty;
139 if (nchars) { 139 if (nchars) {
140 tty.c_lflag &= ~ICANON; 140 tty.c_lflag &= ~ICANON;
141 tty.c_cc[VMIN] = nchars < 256 ? nchars : 255; 141 // Setting it to more than 1 breaks poll():
142 // it blocks even if there's data. !??
143 //tty.c_cc[VMIN] = nchars < 256 ? nchars : 255;
144 /* reads would block only if < 1 char is available */
145 tty.c_cc[VMIN] = 1;
146 /* no timeout (reads block forever) */
147 tty.c_cc[VTIME] = 0;
142 } 148 }
143 if (read_flags & BUILTIN_READ_SILENT) { 149 if (read_flags & BUILTIN_READ_SILENT) {
144 tty.c_lflag &= ~(ECHO | ECHOK | ECHONL); 150 tty.c_lflag &= ~(ECHO | ECHOK | ECHONL);