From 5f9a86dd452ee2d9d9c3695c53acb756f05422fe Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Mon, 15 Feb 2021 12:18:59 -0700 Subject: [PATCH] Girocco/Validator.pm: sanctify non-default Config.pm When a non-default Config.pm is used via the GIROCCO_CONF mechanism, the global $INC{'Girocco/Config.pm'} element never gets set. If the install process then attempts to use some utility that directly "use"s Girocco::Config the default config will be included at that point and overwrite the custom settings pointed at by GIROCCO_CONF. Since the only time it's okay to not explicitly use Girocco::Validator after $GIROCCO_CONF is once the config has been frozen (it's always frozen under the Girocco::Config name), make Validator.pm sanctify the use of a non-default Config.pm by magically setting the missing $INC{'Girocco/Config.pm'} when it does its thing. It does, after all, actually contain a `package Girocco::Config` line; it's not unreasonable to think it might set $INC{'Girocco/Config.pm'}. Signed-off-by: Kyle J. McKay --- Girocco/Validator.pm | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Girocco/Validator.pm b/Girocco/Validator.pm index 43dbec2..78876aa 100644 --- a/Girocco/Validator.pm +++ b/Girocco/Validator.pm @@ -21,6 +21,12 @@ use strict; use warnings; no strict 'vars'; # required since Config.pm declares the variables +BEGIN { + # Makes non-Config modules work with non-default Config + exists($INC{'Girocco/Config.pm'}) or + $INC{'Girocco/Config.pm'} = $INC{'Girocco/Validator.pm'}; +} + # ## ------------------------ ## Sanity checks & defaults -- 2.11.4.GIT