From b9a1b02dee2b82e4e4a580c446a1e022aa96166d Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Mon, 30 Jan 2023 12:24:34 +0000 Subject: ash,make: fix CRLF handling Fix remove_cr() so it only removes CRs which are part of a CRLF pair, not every CR. Add a test case for the shell. --- testsuite/sh.tests | 6 ++++++ win32/mingw.c | 5 +++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/testsuite/sh.tests b/testsuite/sh.tests index 2a510fb25..872611a1b 100755 --- a/testsuite/sh.tests +++ b/testsuite/sh.tests @@ -88,3 +88,9 @@ IyEvYmluL3NoICAtIAplY2hvICJIZWxsbyB3b3JsZCIK ==== " rm -f shebang_leading_argument_trailing_space.sh + +testing "remove CRs from string being evaluated" \ + "sh -c \"$(printf 'set -e\r\necho Hello world\r\n')\"" \ + "Hello world\n" "" "" + +exit $FAILCOUNT diff --git a/win32/mingw.c b/win32/mingw.c index 5cd7e74db..4d07a24e5 100644 --- a/win32/mingw.c +++ b/win32/mingw.c @@ -2030,8 +2030,9 @@ size_t FAST_FUNC remove_cr(char *p, size_t len) ssize_t i, j; for (i=j=0; i