Skip to content

Commit

Permalink
Add :throw named argument to run()
Browse files Browse the repository at this point in the history
Basically, this will just run the same logic as sinking, causing a
failure to be thrown immediately, instead of silently continuing.
And this not producing any output with :out.

Also some style changes to run() to make it better readable
  • Loading branch information
lizmat committed May 18, 2021
1 parent 21a60e1 commit 6408e94
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions src/core.c/Proc.pm6
Expand Up @@ -237,11 +237,26 @@ my class Proc {
}

proto sub run(|) {*}
multi sub run(*@args where .so, :$in = '-', :$out = '-', :$err = '-',
Bool :$bin, Bool :$chomp = True, Bool :$merge,
Str :$enc, Str:D :$nl = "\n", :$cwd = $*CWD, :$env, :$arg0, :$win-verbatim-args = False) {
my $proc := Proc.new(:$in, :$out, :$err, :$bin, :$chomp, :$merge, :$enc, :$nl);
multi sub run(*@args where .so,
:$in = '-',
:$out = '-',
:$err = '-',
Bool :$bin,
Bool :$chomp = True,
Bool :$merge,
Str :$enc,
Str :$nl = "\n",
:$cwd = $*CWD,
:$env,
:$arg0,
:$win-verbatim-args = False,
:$throw,
--> Proc:D) {
my $proc := Proc.new(
:$in, :$out, :$err, :$bin, :$chomp, :$merge, :$enc, :$nl
);
$proc.spawn(@args, :$cwd, :$env, :$arg0, :$win-verbatim-args);
$proc.sink if $throw;
$proc
}

Expand Down

0 comments on commit 6408e94

Please sign in to comment.