diff options
Diffstat (limited to 'shell/shell_common.c')
| -rw-r--r-- | shell/shell_common.c | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/shell/shell_common.c b/shell/shell_common.c index 7fb5f8c58..2a876acac 100644 --- a/shell/shell_common.c +++ b/shell/shell_common.c | |||
| @@ -209,8 +209,13 @@ shell_builtin_read(struct builtin_read_params *params) | |||
| 209 | * 32-bit unix time wrapped (year 2038+). | 209 | * 32-bit unix time wrapped (year 2038+). |
| 210 | */ | 210 | */ |
| 211 | if (timeout <= 0) { /* already late? */ | 211 | if (timeout <= 0) { /* already late? */ |
| 212 | #if ENABLE_PLATFORM_MINGW32 | ||
| 213 | retval = (const char *)(uintptr_t)2; | ||
| 214 | break; | ||
| 215 | #else | ||
| 212 | retval = (const char *)(uintptr_t)1; | 216 | retval = (const char *)(uintptr_t)1; |
| 213 | goto ret; | 217 | goto ret; |
| 218 | #endif | ||
| 214 | } | 219 | } |
| 215 | } | 220 | } |
| 216 | 221 | ||
| @@ -228,8 +233,14 @@ shell_builtin_read(struct builtin_read_params *params) | |||
| 228 | if (poll(pfd, 1, timeout) <= 0) { | 233 | if (poll(pfd, 1, timeout) <= 0) { |
| 229 | /* timed out, or EINTR */ | 234 | /* timed out, or EINTR */ |
| 230 | err = errno; | 235 | err = errno; |
| 236 | #if ENABLE_PLATFORM_MINGW32 | ||
| 237 | /* Windows poll(2) doesn't do EINTR, we timed out */ | ||
| 238 | retval = (const char *)(uintptr_t)2; | ||
| 239 | break; | ||
| 240 | #else | ||
| 231 | retval = (const char *)(uintptr_t)1; | 241 | retval = (const char *)(uintptr_t)1; |
| 232 | goto ret; | 242 | goto ret; |
| 243 | #endif | ||
| 233 | } | 244 | } |
| 234 | #if ENABLE_PLATFORM_MINGW32 | 245 | #if ENABLE_PLATFORM_MINGW32 |
| 235 | if (isatty(fd)) { | 246 | if (isatty(fd)) { |
| @@ -238,15 +249,18 @@ shell_builtin_read(struct builtin_read_params *params) | |||
| 238 | key = windows_read_key(fd, NULL, timeout); | 249 | key = windows_read_key(fd, NULL, timeout); |
| 239 | if (key == 0x03) { | 250 | if (key == 0x03) { |
| 240 | /* ^C pressed */ | 251 | /* ^C pressed */ |
| 241 | retval = (const char *)(uintptr_t)2; | 252 | retval = (const char *)(uintptr_t)3; |
| 242 | goto ret; | 253 | goto ret; |
| 243 | } | 254 | } |
| 244 | else if (key == -1 || (key == 0x1a && bufpos == 0)) { | 255 | else if (key == -1) { |
| 245 | /* timeout or ^Z at start of buffer */ | 256 | /* timeout */ |
| 257 | retval = (const char *)(uintptr_t)2; | ||
| 258 | break; | ||
| 259 | } else if (key == 0x1a && bufpos == 0) { | ||
| 260 | /* ^Z at start of buffer */ | ||
| 246 | retval = (const char *)(uintptr_t)1; | 261 | retval = (const char *)(uintptr_t)1; |
| 247 | goto ret; | 262 | break; |
| 248 | } | 263 | } else if (key == '\b') { |
| 249 | else if (key == '\b') { | ||
| 250 | if (bufpos > 0) { | 264 | if (bufpos > 0) { |
| 251 | --bufpos; | 265 | --bufpos; |
| 252 | ++nchars; | 266 | ++nchars; |
