diff options
author | Pádraig Brady <P@draigBrady.com> | 2013-01-22 01:34:07 +0000 |
---|---|---|
committer | Pádraig Brady <P@draigBrady.com> | 2013-01-26 02:31:59 +0000 |
commit | d302aed182d625281fba87aca3cb513882aa967b (patch) | |
tree | ba7fffb25d51deb1632cebc17456152cd047d329 /tests | |
parent | 51ce0bf8440e18de34586003b1a5d7f568fbf636 (diff) | |
download | coreutils-d302aed182d625281fba87aca3cb513882aa967b.tar.xz |
cut: fix -f to work with the -d$'\n' edge case
* src/cut.c (cut_fields): Handle the edge case where '\n' is
the delimiter, which could be used for example to suppress
the last line if it doesn't contain a '\n'.
* test/misc/cut.pl: Add tests for this edge case.
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/misc/cut.pl | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/misc/cut.pl b/tests/misc/cut.pl index 3ce09bbce..874c16900 100755 --- a/tests/misc/cut.pl +++ b/tests/misc/cut.pl @@ -143,6 +143,16 @@ my @Tests = ['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"}], + # newline processing for fields when -d == '\n' + ['newline-14', "-d'\n'", '-f1', {IN=>"a:1\nb:"}, {OUT=>"a:1\nb:\n"}], + ['newline-15', '-s', "-d'\n'", '-f1', {IN=>"a:1\nb:"}, {OUT=>"a:1\n"}], + ['newline-16', '-s', "-d'\n'", '-f2', {IN=>"\nb"}, {OUT=>""}], + ['newline-17', '-s', "-d'\n'", '-f1', {IN=>"\nb"}, {OUT=>"\n"}], + ['newline-18', "-d'\n'", '-f2', {IN=>"\nb"}, {OUT=>"\nb\n"}], + ['newline-19', "-d'\n'", '-f1', {IN=>"\nb"}, {OUT=>"\nb\n"}], + ['newline-20', '-s', "-d'\n'", '-f1-', {IN=>"\n"}, {OUT=>"\n"}], + ['newline-21', '-s', "-d'\n'", '-f1-', {IN=>"\nb"}, {OUT=>"\n"}], + ['newline-22', "-d'\n'", '-f1-', {IN=>"\nb"}, {OUT=>"\nb\n"}], # New functionality: ['out-delim1', '-c1-3,5-', '--output-d=:', {IN=>"abcdefg\n"}, |