From 85b6a65bf18b5ea3de0cc7a4c0ab4ffbe69bd7bd Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Tue, 29 Nov 2016 20:40:27 -0800 Subject: [PATCH] ExecUtil.pm: allow adjusting the reexec environment Provide functions to examine and alter the environment variables saved in the reexec instance. Signed-off-by: Kyle J. McKay --- Girocco/ExecUtil.pm | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/Girocco/ExecUtil.pm b/Girocco/ExecUtil.pm index ade725a..730a55d 100644 --- a/Girocco/ExecUtil.pm +++ b/Girocco/ExecUtil.pm @@ -229,6 +229,31 @@ sub reexec { return $result; } +sub getenv { + my $self = shift; + my $result = undef; + if (exists($self->{ENV}->{$_[0]})) { + $result = $self->{ENV}->{$_[0]}; + defined($result) or $result = ""; + } + $result; +} + +sub setenv { + my $self = shift; + my ($k, $v) = @_; + if (defined($v)) { + $self->{ENV}->{$k} = $v; + } else { + delete $self->{ENV}->{$k}; + } +} + +sub delenv { + my $self = shift; + $self->setenv($_[0], undef); +} + 1; __END__ @@ -306,6 +331,24 @@ failures on systems where some kinds of initialization can only be performed once for any given pid during its lifetime which is why setting I to true is not recommended. +=item $instance->getenv(I) + +Return the value of environment variable I saved in the instance or +C if it's not part of the saved environment. If the environment +variable I is present in the saved environment then C will +B be returned. + +=item $instance->setenv(I, I) + +=item $instance->setenv(I, undef) + +=item $instance->delenv(I) + +Set the value of environment variable I saved in the instance. If +I is C or omitted or C used then remove the environment +variable named I from the environment saved in the instance -- it is +no error to remove an environment variable that is not present in the instance. + =back =head1 COPYRIGHT -- 2.11.4.GIT