Created
August 24, 2009 22:54
-
-
Save s1n/174282 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sub unsetenv ($key) is export { | |
Q:PIR { | |
.local pmc env | |
env = new ['Env'] | |
$P0 = find_lex "$key" | |
delete env[$P0] | |
}; | |
} | |
sub getenv ($key) is export { | |
my $r = Q:PIR { | |
.local pmc env | |
env = new ['Env'] | |
$P0 = find_lex "$key" | |
$P0 = env[$P0] | |
$S0 = $P0 | |
%r = box $S0 | |
}; | |
return $r; | |
} | |
sub setenv ($key, $val) is export { | |
Q:PIR { | |
.local pmc env | |
env = new ['Env'] | |
$P0 = find_lex "$key" | |
$P1 = find_lex "$val" | |
env[$P0] = $P1 | |
}; | |
} | |
setenv "FOO", 5; | |
say "FOO eq " ~ getenv("FOO"); | |
run "env | grep -i foo"; | |
setenv "FOO", 6; | |
say "FOO eq " ~ getenv("FOO"); | |
run "env | grep -i foo"; | |
unsetenv "FOO"; | |
say "FOO eq " ~ getenv("FOO"); | |
run "env | grep -i foo"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FOO eq 5 | |
FOO=5 | |
FOO eq 6 | |
FOO=6 | |
FOO eq |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment