From f1ef8ac0659a43aecb3c6ae46d3fd85920b6bdba Mon Sep 17 00:00:00 2001 From: wimpunk Date: Sat, 2 Dec 2006 14:40:37 +0000 Subject: [PATCH] Applied help_nonroot.diff: Allow calling the help function as non-root. (submitted by Torsten) git-svn-id: svn+ssh://svn.code.sf.net/p/ddclient/code/trunk/svn@34 3873ddee-7413-0410-b6c4-c2c57c1ab35a --- ddclient | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/ddclient b/ddclient index caaf011..ed5c25d 100755 --- a/ddclient +++ b/ddclient @@ -543,6 +543,12 @@ $result = 'OK'; test_geturl(opt('geturl')) if opt('geturl'); +## process help option +if (opt('help')) { + *STDERR = *STDOUT; + usage(0); +} + ## read config file because 'daemon' mode may be defined there. read_config(define($opt{'file'}, default('file')), \%config, \%globals); init_config(); @@ -1101,16 +1107,14 @@ sub init_config { $config{$h}{'cacheable'} = [ @{$services{$proto}{'cacheable'}} ]; } } - if (opt('help')) { - *STDERR = *STDOUT; - usage(); - } } ###################################################################### ## usage ###################################################################### sub usage { + my $exitcode = 1; + $exitcode = shift if @_ != 0; # use first arg if given my $msg = ''; if (@_) { my $format = shift; @@ -1120,7 +1124,7 @@ sub usage { } printf STDERR "%s%s\n", $msg, $opt_usage; sendmail(); - exit 1; + exit $exitcode; } ######################################################################