aboutsummaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2023-01-31 14:43:28 +0000
committerRon Yorston <rmy@pobox.com>2023-01-31 14:48:43 +0000
commit2d848eba575c32f797cea465b1ccba27467fad45 (patch)
tree171a47c27418a5ab904447c66b8b1fb4c462c53e /shell
parentf3aae6b7c256b1d9faff96f957f32886643bbaa8 (diff)
downloadbusybox-w32-2d848eba575c32f797cea465b1ccba27467fad45.tar.gz
busybox-w32-2d848eba575c32f797cea465b1ccba27467fad45.tar.bz2
busybox-w32-2d848eba575c32f797cea465b1ccba27467fad45.zip
ash: fix CRLF handling
Only remove CRs that are part of a CRLF pair in the output of command substitution. It would be nice to do the same in preadbuffer() but there's a small chance the CRLF might be split between buffers.
Diffstat (limited to 'shell')
-rw-r--r--shell/ash.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/shell/ash.c b/shell/ash.c
index ebed9b50e..7b9b9f1e1 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -7366,9 +7366,14 @@ expbackq(union node *cmd, int flag IF_BASH_PROCESS_SUBST(, int ctl))
7366 7366
7367 /* Eat all trailing newlines */ 7367 /* Eat all trailing newlines */
7368 dest = expdest; 7368 dest = expdest;
7369 for (; dest > ((char *)stackblock() + startloc) && (dest[-1] == '\n' 7369 for (; dest > ((char *)stackblock() + startloc) && dest[-1] == '\n';) {
7370 IF_PLATFORM_MINGW32(|| dest[-1] == '\r'));)
7371 STUNPUTC(dest); 7370 STUNPUTC(dest);
7371#if ENABLE_PLATFORM_MINGW32
7372 if (dest > ((char *)stackblock() + startloc) && dest[-1] == '\r') {
7373 STUNPUTC(dest);
7374 }
7375 }
7376#endif
7372 expdest = dest; 7377 expdest = dest;
7373 7378
7374 if (!(flag & EXP_QUOTED)) 7379 if (!(flag & EXP_QUOTED))