From 0e6ec1fc6439ff3653c123579401f7940e925f10 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 11 Aug 2017 18:20:26 +1200 Subject: Apply sorts to keep output stable Because Perl doesn't sort hash keys (and rightly so), the results are the same but the blocks may not be in the same order, not the lines within each block. We may as well sort them to keep the output stable and improve readability and prevent any confusion. --- checkem | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/checkem b/checkem index c14526b..78386bb 100755 --- a/checkem +++ b/checkem @@ -25,7 +25,7 @@ use File::Find; use Digest; # Version number to make Perl::Critic happy -our $VERSION = 2.9; +our $VERSION = 2.10; # If no arguments, work with the current working directory if ( !@ARGV ) { @@ -119,7 +119,8 @@ for my $fs ( grep { @{$_} > 1 } values %sizes ) { } # Print the groups of matched files (more than one share a checksum in the -# final table) -for my $group ( grep { @{$_} > 1 } values %sums ) { - printf "%s\n\n", join "\n", map { $_->{name} } @{$group}; +# final table); apply gratuitous sorts, just so the output remains the same for +# identical file sets +for my $dig ( sort grep { @{ $sums{$_} } > 1 } keys %sums ) { + printf "%s\n\n", join "\n", sort map { $_->{name} } @{ $sums{$dig} }; } -- cgit v1.2.3