From 99e4b3cb2c8d81e4a36977fc3656d1e4d30b9dd9 Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Tue, 6 Jul 2021 22:12:30 -0700 Subject: [PATCH] shlib.sh: provide var_getconfpath variable Stuff the output of the Girocco::Dumper::GetConfPath function into the `var_getconfpath` variable for use by shell scripts and so forth. It's slightly more reliable than `getconf PATH` as it "sanitizes" the result of `getconf PATH` to exclude any "." components and that makes it helpful to have available for scripts. Signed-off-by: Kyle J. McKay --- shlib.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/shlib.sh b/shlib.sh index c6f1f4b..b4954a0 100644 --- a/shlib.sh +++ b/shlib.sh @@ -53,6 +53,7 @@ _get_girocco_config_pm_var_list() ( # Export all the scalar variables from Girocco::Config to suitable var= lines # prefixing them with 'cfg_'. E.g. $cfg_admin is admin's mail address now # and also setting a 'defined_cfg_' prefix to 1 if they are not undef. + # Always export value of GetConfPath as var_getconfpath. __girocco_conf="$GIROCCO_CONF" [ -n "$__girocco_conf" ] || __girocco_conf="Girocco::Config" [ -z "$basedir" ] || __girocco_extrainc="-I$basedir" @@ -81,8 +82,10 @@ _get_girocco_config_pm_var_list() ( lc($_) eq "path" and next; &$outvar($_, ${$Girocco::Config::{$_}}); } - exists($env->{PATH}) && @{$env->{PATH}} or $env->{PATH} = [GetConfPath()]; - &$outvar("path", ${$env->{PATH}}[0]);' "$__girocco_conf" + my $getconfpath = GetConfPath(); + exists($env->{PATH}) && @{$env->{PATH}} or $env->{PATH} = [$getconfpath]; + &$outvar("path", ${$env->{PATH}}[0]); + &$outvar("var_getconfpath", $getconfpath);' "$__girocco_conf" ) # Returns full command path for "$1" if it's a valid command otherwise returns "$1" @@ -105,6 +108,7 @@ _fcp() { get_girocco_config_var_list() ( # Same as _get_girocco_config_pm_var_list except that # the following variables (all starting with var_) are added: + # var_getconfpath Courtesy of _get_girocco_config_pm_var_list # var_group cfg_owning_group if defined otherwise `id -gn` # var_group_gid group id number of $var_group # var_mirror_uid user id number of $cfg_mirror_user @@ -145,6 +149,7 @@ get_girocco_config_var_list() ( eval "$_cfg_vars" [ -z "$cfg_path" ] || { PATH="$cfg_path" && export PATH; } [ "$1" = "varonly" ] || printf '%s\n' "$_cfg_vars" + [ "$1" != "varonly" ] || printf 'var_getconfpath="%s"\n' "$var_getconfpath" printf 'var_group=%s\n' "${cfg_owning_group:-$(id -gn)}" perl - "$var_group" "$cfg_mirror_user" "$cfg_cgi_user" <<-'PERLPROG' no warnings; -- 2.11.4.GIT