From 837066f71a22405f2376082165b7f670bcb329bc Mon Sep 17 00:00:00 2001 From: Hammat Wele Date: Thu, 2 Oct 2025 19:56:00 +0000 Subject: [PATCH] Bug 36027: (follow-up) Fix the use of --skip-* options --- .../search_for_data_inconsistencies.pl | 37 ++++++++++++++++--- 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/misc/maintenance/search_for_data_inconsistencies.pl b/misc/maintenance/search_for_data_inconsistencies.pl index d7ce1472c3e..84794a8a9ac 100755 --- a/misc/maintenance/search_for_data_inconsistencies.pl +++ b/misc/maintenance/search_for_data_inconsistencies.pl @@ -84,6 +84,9 @@ pod2usage(1) if $options{'help'}; # Set skip options based on check options set_skip_options(); +# Set check options based on skip options +set_check_options(); + # Set all check options to 1 if none are provided, unless specified skip options set_all_check_options_if_none_provided(); @@ -127,10 +130,30 @@ sub set_skip_options { return %options; } -# Set all check options to 1 if none are provided, considering skip options +# Set check options based on skip options +sub set_check_options { + + my @has_skip_option = grep { $options{$_} } grep { /^skip-/ } keys %options; + + #warn $has_skip_option;exit; + if (@has_skip_option) { + + # enable all check-* options + $options{$_} = 1 for grep { /^check-/ } keys %options; + + # disable the corresponding check-* for each active skip-* option + foreach my $key (@has_skip_option) { + my $check_key = $key; + $check_key =~ s/^skip-/check-/; + $options{$check_key} = 0 if exists $options{$check_key}; + } + } + return %options; +} + +# Set all check options to 1 if check-all are provided, considering skip options sub set_all_check_options_if_none_provided { - my $check_all_option_provided = grep { $options{$_} && $_ eq "check-all" } grep { /^check-/ } keys %options; - if ($check_all_option_provided) { + if ( $options{'check-all'} ) { foreach my $key ( keys %options ) { if ( $key =~ /^check-/ ) { my $skip_key = $key; @@ -140,9 +163,11 @@ sub set_all_check_options_if_none_provided { $options{$key} = 1 unless $options{$skip_key}; } } - } elsif ( 0 == grep { $options{$_} && $_ ne "check-all" } grep { /^check-/ } keys %options ) { - handle_invalid_options("No options selected"); - die; + } else { + unless ( grep { $options{$_} && /^(check-|skip-)/ } keys %options ) { + handle_invalid_options("No options selected"); + die; + } } } -- 2.34.1