From 7be4d58b90e5b47120d75fe534a6ec655ad9a11a Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Thu, 28 May 2020 13:37:38 -0400 Subject: [PATCH] Convert invocations of usage() to fatal() The usage text is extremely long which causes the error message to scroll off the top of the screen. Switch to fatal() to avoid this problem. --- ddclient | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/ddclient b/ddclient index f308570..c4de9ac 100755 --- a/ddclient +++ b/ddclient @@ -807,7 +807,10 @@ $result = 'OK'; test_geturl(opt('geturl')) if opt('geturl'); -usage() if opt('help'); +if (opt('help')) { + printf "%s\n", $opt_usage; + exit 0; +} ## read config file because 'daemon' mode may be defined there. read_config(define($opt{'file'}, default('file')), \%config, \%globals); @@ -860,7 +863,7 @@ do { read_cache(opt('cache'), \%cache); print_info() if opt('debug') && opt('verbose'); - usage("invalid argument '-use %s'; possible values are:\n%s", $opt{'use'}, join("\n", ip_strategies_usage())) + fatal("invalid argument '-use %s'; possible values are:\n%s", $opt{'use'}, join("\n", ip_strategies_usage())) unless exists $ip_strategies{lc opt('use')}; $daemon = $opt{'daemon'}; @@ -1327,7 +1330,7 @@ sub init_config { ## sanity check if (defined $opt{'host'} && defined $opt{'retry'}) { - usage("options -retry and -host (or -option host=..) are mutually exclusive"); + fatal("options -retry and -host (or -option host=..) are mutually exclusive"); } ## determine hosts to update (those on the cmd-line, config-file, or failed cached) @@ -1403,16 +1406,6 @@ sub init_config { } } -###################################################################### -## usage -###################################################################### -sub usage { - _msg(1, 1, 'FATAL:', @_) if @_; - printf { @_ ? *STDERR : *STDOUT } "%s\n", $opt_usage; - sendmail() if @_; - exit (@_ ? 1 : 0); -} - ###################################################################### ## process_args - ######################################################################