Skip to content

Commit

Permalink
pass decontainerized ENV to shell/run and spawn
Browse files Browse the repository at this point in the history
  • Loading branch information
FROGGS committed Jan 6, 2014
1 parent 279cb49 commit 9d045f1
Showing 1 changed file with 27 additions and 6 deletions.
33 changes: 27 additions & 6 deletions src/core/control.pm
Original file line number Diff line number Diff line change
Expand Up @@ -182,20 +182,34 @@ my class Proc::Status { ... }

sub run(*@args ($, *@)) {
my $status = Proc::Status.new( :exit(255) );
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)))
}
try {
my Mu $hash := nqp::getattr(%*ENV, EnumMap, '$!storage');
$status.status( nqp::p6box_i(
nqp::spawn(nqp::getattr(@args.eager, List, '$!items'), $*CWD.Str, $hash)
nqp::spawn(nqp::getattr(@args.eager, List, '$!items'), $*CWD.Str, $hash-without)
) );
}
$status
}

sub shell($cmd) {
my $status = Proc::Status.new( :exit(255) );
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)))
}
try {
my Mu $hash := nqp::getattr(%*ENV, EnumMap, '$!storage');
$status.status( nqp::p6box_i(nqp::shell($cmd, $*CWD.Str, $hash)) );
$status.status( nqp::p6box_i(nqp::shell($cmd, $*CWD.Str, $hash-without)) );
}
$status
}
Expand All @@ -219,8 +233,15 @@ sub QX($cmd) {
$result;
#?endif
#?if !parrot
my Mu $env := nqp::getattr(%*ENV, EnumMap, '$!storage');
my Mu $pio := nqp::openpipe(nqp::unbox_s($cmd), $*CWD.Str, $env, '');
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, '');
fail "Unable to execute '$cmd'" unless $pio;
my $result = nqp::p6box_s(nqp::readallfh($pio));
nqp::closefh($pio);
Expand Down

0 comments on commit 9d045f1

Please sign in to comment.