From 8cfe678d99de143946fde9de3536755ee824b9b5 Mon Sep 17 00:00:00 2001 From: Jacob Bachmeyer Date: Sat, 12 Nov 2022 22:11:22 -0600 Subject: [PATCH] Change current zone from a global variable to a constant Only one zone is processed on each run of the tool, and the zone does not change after the command arguments are parsed, so this is appropriate. --- gatekeeper.pl | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/gatekeeper.pl b/gatekeeper.pl index e8a30bc..d5b8a77 100755 --- a/gatekeeper.pl +++ b/gatekeeper.pl @@ -215,7 +215,7 @@ BEGIN { # # These should be changed to constants eventually, since they should not # change after the script is started. - our $zone = ''; + my $ZONE = ''; our $help = ''; our $version = ''; # Set this to 1 or higher to get debug output in the log file. @@ -231,13 +231,14 @@ BEGIN { GetOptions('help' => \$help, 'version' => \$version, - 'zone|z|s=s' => \$zone, + 'zone|z|s=s' => \$ZONE, 'tstampcheck=i' => \$TSTAMPCHECK, 'nomail=i' => \$NOMAIL, 'debug|d=i' => \$DEBUG, 'testing-this-script' => \$TestingMode, ); + constant->import(ZONE => $ZONE); constant->import(DEBUG => $DEBUG); constant->import(NOMAIL => $NOMAIL); constant->import(TSTAMPCHECK => $TSTAMPCHECK); @@ -260,7 +261,6 @@ BEGIN { } } -our $zone; our $help; our $version; @@ -280,11 +280,11 @@ if ($version) { pod2usage(-verbose => 1, -exitval => 0) if ($help); pod2usage(-message => 'ERROR: Required parameter not given or invalid.', -verbose => 0, -exitval => 2) - if (($zone ne 'ftp') && ($zone ne 'alpha') && ($zone ne 'distros')); + if ((ZONE ne 'ftp') && (ZONE ne 'alpha') && (ZONE ne 'distros')); my $zone_tag = 'ftp'; -$zone_tag = 'alpha' if ($zone eq 'alpha'); -$zone_tag = 'gnu+linux-distros' if ($zone eq 'distros'); +$zone_tag = 'alpha' if (ZONE eq 'alpha'); +$zone_tag = 'gnu+linux-distros' if (ZONE eq 'distros'); # Settings to configure: my $package_config_base = "/home/gatekpr/packages"; @@ -395,8 +395,8 @@ gatekeeper itself and these functions may change without notice. our $Log_Tag = 'Test'; } else { our $Log_Tag = 'GNU'; - $Log_Tag = 'Alpha' if ($zone eq 'alpha'); - $Log_Tag = 'Distros' if ($zone eq 'distros'); + $Log_Tag = 'Alpha' if (ZONE eq 'alpha'); + $Log_Tag = 'Distros' if (ZONE eq 'distros'); } # If this is set to a defined value, ftp_syslog will prepend it, inside -- 2.25.1