Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Some more uses of CLONE-HASH-DECONTAINERIZED()
  • Loading branch information
lizmat committed Jan 25, 2015
1 parent e34a9c0 commit a1c8b97
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 43 deletions.
17 changes: 1 addition & 16 deletions src/core/IO/Handle.pm
Expand Up @@ -55,26 +55,11 @@ my class IO::Handle does IO {
if $p {
$!pipe = 1;

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 str $errpath;
$!PIO := nqp::openpipe(
nqp::unbox_s($!path.Str),
nqp::unbox_s($*CWD.Str),
$hash-without,
CLONE-HASH-DECONTAINERIZED(%*ENV),
$errpath,
);
}
Expand Down
14 changes: 5 additions & 9 deletions src/core/Proc/Async.pm
Expand Up @@ -162,14 +162,6 @@ my class Proc::Async {
$!started = True;

my %ENV := $ENV ?? $ENV.hash !! %*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 $args-without := nqp::list(nqp::decont($!path.Str));
for @!args.eager {
Expand Down Expand Up @@ -197,7 +189,11 @@ my class Proc::Async {
nqp::bindkey($callbacks, 'write', True) if $.w;

$!process_handle := nqp::spawnprocasync($scheduler.queue,
$args-without, $*CWD.Str, $hash-without, $callbacks);
$args-without,
$*CWD.Str,
CLONE-HASH-DECONTAINERIZED(%ENV),
$callbacks,
);

Promise.allof( $!exit_promise, @!promises ).then( {
for @!promises -> $promise {
Expand Down
28 changes: 10 additions & 18 deletions src/core/control.pm
Expand Up @@ -232,36 +232,28 @@ 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)))
}
my Mu $args-without := nqp::list();
for @args.eager {
nqp::push($args-without, nqp::decont(~$_));
}
try {
$status.status( nqp::p6box_i( nqp::spawn($args-without, $*CWD.Str, $hash-without) ) );
$status.status(nqp::p6box_i(nqp::spawn(
$args-without,
$*CWD.Str,
CLONE-HASH-DECONTAINERIZED(%*ENV),
)));
}
$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 {
$status.status( nqp::p6box_i(nqp::shell($cmd, $*CWD.Str, $hash-without)) );
$status.status(nqp::p6box_i(nqp::shell(
$cmd,
$*CWD.Str,
CLONE-HASH-DECONTAINERIZED(%*ENV),
)));
}
$status
}
Expand Down

0 comments on commit a1c8b97

Please sign in to comment.