Skip to content

Commit

Permalink
Fix regression in qx//
Browse files Browse the repository at this point in the history
The Great Proc Refactor™[1] accidentally created a condition where
a Proc returned from a try {} was being sunk. This caused qx// with
processes that returned a non-zero exit status to explode.

Fix by simplifying the code

[1] 2ccd5cb
  • Loading branch information
zoffixznet committed Jun 16, 2017
1 parent 5e03773 commit c532b79
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions src/core/Proc.pm
Expand Up @@ -190,15 +190,8 @@ sub shell($cmd, :$in = '-', :$out = '-', :$err = '-',

sub QX($cmd, :$cwd = $*CWD, :$env) {
my $proc = Proc.new(:out);
my $status := $proc.shell($cmd, :$cwd, :$env);
my $result;
try {
$result := $proc.out.slurp;
$status := $proc.out.close;
}
$result.DEFINITE
?? $result
!! Failure.new("Unable to read from '$cmd'")
$proc.shell($cmd, :$cwd, :$env);
$proc.out.slurp(:close) // Failure.new("Unable to read from '$cmd'")
}

# vim: ft=perl6 expandtab sw=4

0 comments on commit c532b79

Please sign in to comment.