Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'run' of github.com:rakudo/rakudo into nom
  • Loading branch information
FROGGS committed Oct 29, 2013
2 parents 6f5ceb8 + ea5c22f commit 0eda3d3
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 26 deletions.
27 changes: 27 additions & 0 deletions src/core/OS.pm
@@ -1,3 +1,30 @@
sub gethostname( --> Str){
return nqp::p6box_s(nqp::gethostname());
}

my class Proc::Status {
has $.exit;
has $.pid;
has $.signal;

#~ method exit() { $!exit }
#~ method pid() { $!pid }
#~ method signal() { $!signal }

proto method status(|) { * }
multi method status($new_status) {
$!exit = $new_status +> 8;
$!signal = $new_status +& 0xFF;
}
multi method status() {
($!exit +< 8) +| $!signal
}

method Numeric {
$!exit
}

method Bool {
$!exit == 0
}
}
35 changes: 9 additions & 26 deletions src/core/control.pm
Expand Up @@ -166,43 +166,26 @@ sub exit($status = 0) {
$status;
}

my class Proc::Status { ... }

sub run(*@args ($, *@)) {
my $error_code;
my $status = Proc::Status.new( :exit(255) );
try {
#?if parrot
nqp::chdir($*CWD);
$error_code = nqp::p6box_i(
pir::spawnw__IP(
nqp::getattr(
@args.eager,
List,
'$!items'
)
)
) +> 8;
#?endif
#?if !parrot
my Mu $hash := nqp::getattr(%*ENV, EnumMap, '$!storage');
$error_code = nqp::p6box_i(
$status.status( nqp::p6box_i(
nqp::spawn(nqp::getattr(@args.eager, List, '$!items'), $*CWD.Str, $hash)
) +> 8;
#?endif
CATCH {
default {
$error_code = 1;
}
}
) );
}
$error_code but !$error_code;
$status
}

sub shell($cmd) {
my $status = 255;
my $status = Proc::Status.new( :exit(255) );
try {
my Mu $hash := nqp::getattr(%*ENV, EnumMap, '$!storage');
$status = nqp::p6box_i(nqp::shell($cmd, $*CWD.Str, $hash));
$status.status( nqp::p6box_i(nqp::shell($cmd, $*CWD.Str, $hash)) );
}
$status;
$status
}

# XXX: Temporary definition of $Inf and $NaN until we have constants ava
Expand Down

0 comments on commit 0eda3d3

Please sign in to comment.