mirror of
git://git.sv.gnu.org/coreutils.git
synced 2026-04-21 03:12:48 +02:00
cat: extend --show-ends to show \r\n as ^M$
- \r\n is common a line end combination - catting such a file without options causes it to display normally - overwriting the first char with $, loses info * src/cat.c (cat): Convert \r preceeding a \n to ^M. * tests/misc/cat-E.sh: New test. * tests/local.mk: Reference new test. * tests/misc/cat-proc.sh: Fix typo. * doc/coreutils.texi (cat invocation): Mention the new behavior. * NEWS: Mention the improvement.
This commit is contained in:
@@ -279,6 +279,7 @@ all_tests = \
|
||||
tests/misc/wc-nbsp.sh \
|
||||
tests/misc/wc-parallel.sh \
|
||||
tests/misc/wc-proc.sh \
|
||||
tests/misc/cat-E.sh \
|
||||
tests/misc/cat-proc.sh \
|
||||
tests/misc/cat-buf.sh \
|
||||
tests/misc/cat-self.sh \
|
||||
|
||||
30
tests/misc/cat-E.sh
Executable file
30
tests/misc/cat-E.sh
Executable file
@@ -0,0 +1,30 @@
|
||||
#!/bin/sh
|
||||
# Copyright (C) 2021 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
|
||||
print_ver_ cat
|
||||
|
||||
# \r followed by \n is displayed as ^M$
|
||||
# Up to and including 8.32 the $ would have displayed at the start of the line
|
||||
# overwriting the first character
|
||||
printf 'a\rb\r\nc\n\r\nd\r' > 'in' || framework_failure_
|
||||
printf 'a\rb^M$\nc$\n^M$\nd^M' > 'exp' || framework_failure_
|
||||
|
||||
cat -E 'in' > out || fail=1
|
||||
|
||||
compare exp out || fail=1
|
||||
|
||||
Exit $fail
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/bin/sh
|
||||
# Ensure that cat -E produces same output as cat, module '$'s,
|
||||
# Ensure that cat -E produces same output as cat, modulo '$'s,
|
||||
# even when applied to a file in /proc.
|
||||
|
||||
# Copyright (C) 2006-2021 Free Software Foundation, Inc.
|
||||
|
||||
Reference in New Issue
Block a user