Objective
Isolate environmental variable changes to a code block.
Background
If I want to create a batch scrip
Forgive me if I've missed something as there parts of this post I'm a bit unclear on.
I would use the scope modifies $local
, $script
and $global
modifiers.
Example
$env:TEST="EN"
function tt {
$local:env:TEST="GB"
($local:env:TEST)
}
$t = {
$local:env:TEST="DE"
($local:env:TEST)
}
($env:TEST)
tt
($env:TEST)
. $t
($env:TEST)
Output with comments
EN # ($env:TEST)
GB # tt
EN # ($env:TEST)
DE # . $t
EN # ($env:TEST)