aboutsummaryrefslogtreecommitdiff
path: root/shell/shell_common.c
diff options
context:
space:
mode:
Diffstat (limited to 'shell/shell_common.c')
-rw-r--r--shell/shell_common.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/shell/shell_common.c b/shell/shell_common.c
index c0dd32fb4..eb2c4fbf5 100644
--- a/shell/shell_common.c
+++ b/shell/shell_common.c
@@ -273,11 +273,35 @@ shell_builtin_read(struct builtin_read_params *params)
273 273
274 c = buffer[bufpos]; 274 c = buffer[bufpos];
275#if ENABLE_PLATFORM_MINGW32 275#if ENABLE_PLATFORM_MINGW32
276# if !ENABLE_ASH_IGNORE_CR
276 if (c == '\r') 277 if (c == '\r')
277 continue; 278 continue;
279# else
280 if (c == '\n') {
281 if (backslash == 2 || (bufpos > 0 && buffer[bufpos - 1] == '\r')) {
282 /* We saw either:
283 * - BS CR LF: remove CR, fall through to ignore escaped LF
284 * and exit BS context.
285 * - CR LF not in BS context: replace CR with LF */
286 buffer[--bufpos] = c;
287 ++nchars;
288 }
289 } else if (backslash == 2) {
290 /* We saw BS CR ??, keep escaped CR, exit BS context,
291 * process ?? */
292 backslash = 0;
293 }
294# endif
278#endif 295#endif
279 if (!(read_flags & BUILTIN_READ_RAW)) { 296 if (!(read_flags & BUILTIN_READ_RAW)) {
280 if (backslash) { 297 if (backslash) {
298#if ENABLE_ASH_IGNORE_CR
299 if (c == '\r') {
300 /* We have BS CR, keep CR for now, might see LF next */
301 backslash = 2;
302 goto put;
303 }
304#endif
281 backslash = 0; 305 backslash = 0;
282 if (c != '\n') 306 if (c != '\n')
283 goto put; 307 goto put;