From: Steve Hancock Date: Wed, 1 May 2024 16:32:16 +0000 (-0700) Subject: catch ambiguous entries commands which exit early (c333) X-Git-Tag: 20240511~6 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=ebecca565a76749d2440c55117e9799ce5109f67;p=perltidy.git catch ambiguous entries commands which exit early (c333) --- diff --git a/lib/Perl/Tidy.pm b/lib/Perl/Tidy.pm index 1a8cb975..fefca32c 100644 --- a/lib/Perl/Tidy.pm +++ b/lib/Perl/Tidy.pm @@ -4529,6 +4529,19 @@ sub _process_command_line { } } + # The above commands processed before disambiguation and then Exited. So + # we need to check below to see if the user entered something like + # '-dump-t' or '-he'. This will slip past here and not get processed. + my %early_exit_commands = ( + 'help' => 'h', + 'version' => 'v', + 'dump-defaults' => 'ddf', + 'dump-integer-option-range' => 'dior', + 'dump-long-names' => 'dln', + 'dump-short-names' => 'dsn', + 'dump-token-types' => 'dtt', + ); + if ( $saw_dump_profile && $saw_ignore_profile ) { Warn("No profile to dump because of -npro\n"); Exit(1); @@ -4684,6 +4697,16 @@ EOM Die("Error on command line; for help try 'perltidy -h'\n"); } + # Catch ambiguous entries which should have exited above (c333) + foreach my $long_name ( keys %early_exit_commands ) { + if ( $Opts{$long_name} ) { + my $short_name = $early_exit_commands{$long_name}; + Die(<