Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add CLONE-HASH-DECONTAINERIZED helper sub
  • Loading branch information
lizmat committed Jan 25, 2015
1 parent 225cf21 commit e34a9c0
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions src/core/control.pm
Expand Up @@ -280,15 +280,9 @@ sub QX($cmd) {
$result;
#?endif
#?if !parrot
my Mu $hash-with-containers := nqp::getattr(%*ENV, EnumMap, '$!storage');
my Mu $hash-without := nqp::hash();
my Mu $enviter := nqp::iterator($hash-with-containers);
my $envelem;
while $enviter {
$envelem := nqp::shift($enviter);
nqp::bindkey($hash-without, nqp::iterkey_s($envelem), nqp::decont(nqp::iterval($envelem)))
}
my Mu $pio := nqp::openpipe(nqp::unbox_s($cmd), $*CWD.Str, $hash-without, '');
my Mu $pio := nqp::openpipe(
nqp::unbox_s($cmd), $*CWD.Str, CLONE-HASH-DECONTAINERIZED(%*ENV), ''
);
fail "Unable to execute '$cmd'" unless $pio;
my $result = nqp::p6box_s(nqp::readallfh($pio));
nqp::closefh($pio);
Expand All @@ -308,4 +302,16 @@ sub NOT_ALL_DEFINED_TYPE(\values,\type) {
False;
}

sub CLONE-HASH-DECONTAINERIZED(\hash) {
my Mu $hash-with-containers := nqp::getattr(hash,EnumMap,'$!storage');
my Mu $hash-without := nqp::hash();
my Mu $enviter := nqp::iterator($hash-with-containers);
my $envelem;
while $enviter {
$envelem := nqp::shift($enviter);
nqp::bindkey($hash-without, nqp::iterkey_s($envelem), nqp::decont(nqp::iterval($envelem)))
}
$hash-without;
}

# vim: ft=perl6 expandtab sw=4

0 comments on commit e34a9c0

Please sign in to comment.