From: Pádraig Brady
Date: Mon, 11 Feb 2019 01:40:36 +0000 (-0800) Subject: comm,join: ensure warnings are apparent upon exit X-Git-Tag: v8.31~30 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=636cbdb77b598109b7073a4e990643b956727cb6;p=thirdparty%2Fcoreutils.git comm,join: ensure warnings are apparent upon exit * src/comm.c (main): Output a warning right before exit, in case previous errors have scrolled from view. * src/join.c (main): Likewise. * tests/misc/comm.pl: Addjust accordingly. * tests/misc/join.pl: Likewise. Fixes https://bugs.gnu.org/34347 --- diff --git a/src/comm.c b/src/comm.c index da8d5cfa81..3e8cf18651 100644 --- a/src/comm.c +++ b/src/comm.c @@ -493,7 +493,7 @@ main (int argc, char **argv) compare_files (argv + optind); if (issued_disorder_warning[0] || issued_disorder_warning[1]) - return EXIT_FAILURE; + die (EXIT_FAILURE, 0, _("input is not in sorted order")); else return EXIT_SUCCESS; } diff --git a/src/join.c b/src/join.c index 7c75c76b90..dd0ce42bcd 100644 --- a/src/join.c +++ b/src/join.c @@ -1193,7 +1193,7 @@ main (int argc, char **argv) die (EXIT_FAILURE, errno, "%s", quotef (g_names[1])); if (issued_disorder_warning[0] || issued_disorder_warning[1]) - return EXIT_FAILURE; + die (EXIT_FAILURE, 0, _("input is not in sorted order")); else return EXIT_SUCCESS; } diff --git a/tests/misc/comm.pl b/tests/misc/comm.pl index 2e87f8080c..61857f3730 100755 --- a/tests/misc/comm.pl +++ b/tests/misc/comm.pl @@ -89,7 +89,8 @@ my @Tests = # out-of-order input ['ooo', {IN=>{a=>"1\n3"}}, {IN=>{b=>"3\n2"}}, {EXIT=>1}, {OUT => "1\n\t\t3\n\t2\n"}, - {ERR => "$prog: file 2 is not in sorted order\n"}], + {ERR => "$prog: file 2 is not in sorted order\n" + . "$prog: input is not in sorted order\n"}], # out-of-order input, fatal ['ooo2', '--check-order', {IN=>{a=>"1\n3"}}, {IN=>{b=>"3\n2"}}, {EXIT=>1}, @@ -104,23 +105,27 @@ my @Tests = ['ooo4', {IN=>{a=>"3\n1\n0"}}, {IN=>{b=>"3\n2\n0"}}, {EXIT=>1}, {OUT => "\t\t3\n1\n0\n\t2\n\t0\n"}, {ERR => "$prog: file 1 is not in sorted order\n". - "$prog: file 2 is not in sorted order\n" }], + "$prog: file 2 is not in sorted order\n" + . "$prog: input is not in sorted order\n"}], # both inputs out-of-order on last pair ['ooo5', {IN=>{a=>"3\n1"}}, {IN=>{b=>"3\n2"}}, {EXIT=>1}, {OUT => "\t\t3\n1\n\t2\n"}, {ERR => "$prog: file 1 is not in sorted order\n". - "$prog: file 2 is not in sorted order\n" }], + "$prog: file 2 is not in sorted order\n" + . "$prog: input is not in sorted order\n"}], # first input out-of-order extended ['ooo5b', {IN=>{a=>"0\n3\n1"}}, {IN=>{b=>"2\n3"}}, {EXIT=>1}, {OUT => "0\n\t2\n\t\t3\n1\n"}, - {ERR => "$prog: file 1 is not in sorted order\n"}], + {ERR => "$prog: file 1 is not in sorted order\n" + . "$prog: input is not in sorted order\n"}], # second input out-of-order extended ['ooo5c', {IN=>{a=>"0\n3"}}, {IN=>{b=>"2\n3\n1"}}, {EXIT=>1}, {OUT => "0\n\t2\n\t\t3\n\t1\n"}, - {ERR => "$prog: file 2 is not in sorted order\n"}], + {ERR => "$prog: file 2 is not in sorted order\n" + . "$prog: input is not in sorted order\n"}], # both inputs out-of-order, but fully pairable ['ooo6', {IN=>{a=>"2\n1\n0"}}, {IN=>{b=>"2\n1\n0"}}, {EXIT=>0}, diff --git a/tests/misc/join.pl b/tests/misc/join.pl index 0030f76c98..1e15b29b2b 100755 --- a/tests/misc/join.pl +++ b/tests/misc/join.pl @@ -216,13 +216,17 @@ my @tv = ( ['chkodr-5d', '', ["a\nx\n\n", "b\ny\n\n"], "", 1, "$prog: chkodr-5d.1:3: is not sorted: \n" . - "$prog: chkodr-5d.2:3: is not sorted: \n"], + "$prog: chkodr-5d.2:3: is not sorted: \n" . + "$prog: input is not in sorted order\n" + ], # Similar, but make it so each offending line has no newline. ['chkodr-5e', '', ["a\nx\no", "b\ny\np"], "", 1, "$prog: chkodr-5e.1:3: is not sorted: o\n" . - "$prog: chkodr-5e.2:3: is not sorted: p\n"], + "$prog: chkodr-5e.2:3: is not sorted: p\n" . + "$prog: input is not in sorted order\n" + ], # Without order check, both inputs out of order and some lines # unpairable. This is NOT supported by the GNU extension. All that