From 2d848eba575c32f797cea465b1ccba27467fad45 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Tue, 31 Jan 2023 14:43:28 +0000 Subject: 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. --- shell/ash.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'shell') 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)) /* Eat all trailing newlines */ dest = expdest; - for (; dest > ((char *)stackblock() + startloc) && (dest[-1] == '\n' - IF_PLATFORM_MINGW32(|| dest[-1] == '\r'));) + for (; dest > ((char *)stackblock() + startloc) && dest[-1] == '\n';) { STUNPUTC(dest); +#if ENABLE_PLATFORM_MINGW32 + if (dest > ((char *)stackblock() + startloc) && dest[-1] == '\r') { + STUNPUTC(dest); + } + } +#endif expdest = dest; if (!(flag & EXP_QUOTED)) -- cgit v1.2.3-55-g6feb