diff options
author | Ron Yorston <rmy@pobox.com> | 2023-02-10 12:54:03 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2023-02-10 13:21:02 +0000 |
commit | d9916c6344c806696554115baa764eea09ca5f08 (patch) | |
tree | a25f6f4aaf4e91915b615af7e4bbc09bd68f6ac9 /testsuite | |
parent | 4b894b60ae377ee2a04ae209c14bb1e714ecf6f4 (diff) | |
download | busybox-w32-d9916c6344c806696554115baa764eea09ca5f08.tar.gz busybox-w32-d9916c6344c806696554115baa764eea09ca5f08.tar.bz2 busybox-w32-d9916c6344c806696554115baa764eea09ca5f08.zip |
ash: remove CRs from CRLF during field splitting
Commit e371e46fa0 (shell: add \r to IFS) added '\r' to the IFS
variable so field splitting would remove carriage returns.
Rather than change IFS, remove CRs preceding LFs in regions
being scanned for field splitting before IFS is applied. This
prevents free-standing CRs from being removed.
Costs 112-120 bytes.
(GitHub issue #285)
Diffstat (limited to 'testsuite')
-rwxr-xr-x | testsuite/sh.tests | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/testsuite/sh.tests b/testsuite/sh.tests index 872611a1b..6fc3ca104 100755 --- a/testsuite/sh.tests +++ b/testsuite/sh.tests | |||
@@ -89,8 +89,12 @@ IyEvYmluL3NoICAtIAplY2hvICJIZWxsbyB3b3JsZCIK | |||
89 | " | 89 | " |
90 | rm -f shebang_leading_argument_trailing_space.sh | 90 | rm -f shebang_leading_argument_trailing_space.sh |
91 | 91 | ||
92 | testing "remove CRs from string being evaluated" \ | 92 | testing "sh remove CRs from string being evaluated" \ |
93 | "sh -c \"$(printf 'set -e\r\necho Hello world\r\n')\"" \ | 93 | "sh -c \"$(printf 'set -e\r\necho Hello world\r\n')\"" \ |
94 | "Hello world\n" "" "" | 94 | "Hello world\n" "" "" |
95 | 95 | ||
96 | testing "sh preserve lone CRs during field splitting" \ | ||
97 | "sh input" \ | ||
98 | "Hello\r world\n" "echo \$(printf \"Hello\\\\r\\\\r\\\\nworld\\\\r\\\\n\")" "" | ||
99 | |||
96 | exit $FAILCOUNT | 100 | exit $FAILCOUNT |