From: Jacob Bachmeyer Date: Sun, 13 Nov 2022 04:17:17 +0000 (-0600) Subject: Change storage of other mode flags to constants X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=3b10c53163ee3417b0607078c71708627392ba45;p=gatekeeper.git Change storage of other mode flags to constants This eliminates the global variables previously used to indicate if the --help and/or --version flags had been specified and allows the relevant conditionals to be resolved during the compilation phase. --- diff --git a/gatekeeper.pl b/gatekeeper.pl index d5b8a77..def6114 100755 --- a/gatekeeper.pl +++ b/gatekeeper.pl @@ -210,14 +210,10 @@ my $URL = "http://www.gnu.org/prep/maintain/html_node/Automated-FTP-Uploads.html"; BEGIN { - # These must be declared "our" so that the actual variable with the data - # (in the symbol table) will remain available after the BEGIN block. - # - # These should be changed to constants eventually, since they should not - # change after the script is started. my $ZONE = ''; - our $help = ''; - our $version = ''; + my $want_help = ''; + my $want_version = ''; + # Set this to 1 or higher to get debug output in the log file. my $DEBUG = 1; @@ -229,8 +225,8 @@ BEGIN { my $TestingMode = 0; - GetOptions('help' => \$help, - 'version' => \$version, + GetOptions('help' => \$want_help, + 'version' => \$want_version, 'zone|z|s=s' => \$ZONE, 'tstampcheck=i' => \$TSTAMPCHECK, 'nomail=i' => \$NOMAIL, @@ -243,6 +239,9 @@ BEGIN { constant->import(NOMAIL => $NOMAIL); constant->import(TSTAMPCHECK => $TSTAMPCHECK); + constant->import(WANT_HELP => $want_help); + constant->import(WANT_VERSION => $want_version); + constant->import(IN_TEST_MODE => $TestingMode); if ($TestingMode) { @@ -261,10 +260,7 @@ BEGIN { } } -our $help; -our $version; - -if ($version) { +if (WANT_VERSION) { print "\nThis is $NAME protocol version $VERSION ($DATE)\n"; print $COPYRIGHT_NOTICE; print "License: $LICENSE\n"; @@ -277,7 +273,7 @@ if ($version) { exit 0; } -pod2usage(-verbose => 1, -exitval => 0) if ($help); +pod2usage(-verbose => 1, -exitval => 0) if WANT_HELP; pod2usage(-message => 'ERROR: Required parameter not given or invalid.', -verbose => 0, -exitval => 2) if ((ZONE ne 'ftp') && (ZONE ne 'alpha') && (ZONE ne 'distros'));