From 9e659a18ebdd5d7f0e57111403197b718f38fbd8 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Mon, 24 Jun 2024 03:15:14 -0400 Subject: [PATCH] Move `--help` processing to `%opt` --- ddclient.in | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/ddclient.in b/ddclient.in index 99edd71..bd96d39 100755 --- a/ddclient.in +++ b/ddclient.in @@ -1245,17 +1245,16 @@ my @opt = ( "", nic_examples(), ); +$opt{'help'} = sub { + print(usage(@opt), "\n"); + $opt{'version'}('', ''); +}; sub main { process_args(@opt); $saved_recap = ''; %saved_opt = %opt; $result = 'OK'; - if (opt('help')) { - print(usage(@opt), "\n"); - $opt{'version'}('', ''); - } - ## read config file because 'daemon' mode may be defined there. read_config($opt{'file'} // default('file'), \%config, \%globals); init_config(); @@ -2126,7 +2125,7 @@ sub process_args { $opt{$key} //= undef; } if (!GetOptions(\%opt, @spec)) { - $opt{"help"} = 1; + $opt{'help'}('', ''); } }