summaryrefslogtreecommitdiff
path: root/tests/misc/cut.pl
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2013-01-21 15:37:37 +0000
committerPádraig Brady <P@draigBrady.com>2013-01-26 02:31:53 +0000
commit51ce0bf8440e18de34586003b1a5d7f568fbf636 (patch)
tree03bb7348eb727280dbc428072434d32dfcc96908 /tests/misc/cut.pl
parenta46d8d02f2b0e49d851a45e63420744b10a10ed4 (diff)
downloadcoreutils-51ce0bf8440e18de34586003b1a5d7f568fbf636.tar.xz
cut: with -f, process each line independently
Previously line N+1 was inspected before line N was fully output, which causes output ordering issues at the terminal or delays from intermittent sources like tail -f. * src/cut.c (cut_fields): Adjust so that we record the previous output character so we can use that info to determine wether to output a '\n' or not. * tests/misc/cut.pl: Add tests to ensure existing functionality isn't broken. * NEWS: Mention the fix. Fixes bug http://bugs.gnu.org/13498
Diffstat (limited to 'tests/misc/cut.pl')
-rwxr-xr-xtests/misc/cut.pl15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/misc/cut.pl b/tests/misc/cut.pl
index c9cff1a65..3ce09bbce 100755
--- a/tests/misc/cut.pl
+++ b/tests/misc/cut.pl
@@ -129,6 +129,21 @@ my @Tests =
['8bit-delim', '-d', "\255", '--out=_', '-f2,3', {IN=>"a\255b\255c\n"},
{OUT=>"b_c\n"}],
+ # newline processing for fields
+ ['newline-1', '-f1-', {IN=>"a\nb"}, {OUT=>"a\nb\n"}],
+ ['newline-2', '-f1-', {IN=>""}, {OUT=>""}],
+ ['newline-3', '-d:', '-f1', {IN=>"a:1\nb:2\n"}, {OUT=>"a\nb\n"}],
+ ['newline-4', '-d:', '-f1', {IN=>"a:1\nb:2"}, {OUT=>"a\nb\n"}],
+ ['newline-5', '-d:', '-f2', {IN=>"a:1\nb:2\n"}, {OUT=>"1\n2\n"}],
+ ['newline-6', '-d:', '-f2', {IN=>"a:1\nb:2"}, {OUT=>"1\n2\n"}],
+ ['newline-7', '-s', '-d:', '-f1', {IN=>"a:1\nb:2"}, {OUT=>"a\nb\n"}],
+ ['newline-8', '-s', '-d:', '-f1', {IN=>"a:1\nb:2\n"}, {OUT=>"a\nb\n"}],
+ ['newline-9', '-s', '-d:', '-f1', {IN=>"a1\nb2"}, {OUT=>""}],
+ ['newline-10', '-s', '-d:', '-f1,2', {IN=>"a:1\nb:2"}, {OUT=>"a:1\nb:2\n"}],
+ ['newline-11', '-s', '-d:', '-f1,2', {IN=>"a:1\nb:2\n"}, {OUT=>"a:1\nb:2\n"}],
+ ['newline-12', '-s', '-d:', '-f1', {IN=>"a:1\nb:"}, {OUT=>"a\nb\n"}],
+ ['newline-13', '-d:', '-f1-', {IN=>"a1:\n:"}, {OUT=>"a1:\n:\n"}],
+
# New functionality:
['out-delim1', '-c1-3,5-', '--output-d=:', {IN=>"abcdefg\n"},
{OUT=>"abc:efg\n"}],