Skip to content

Instantly share code, notes, and snippets.

@Xliff
Created September 16, 2021 15:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Xliff/b9d290cc5262dae05c0738111434d7e9 to your computer and use it in GitHub Desktop.
Save Xliff/b9d290cc5262dae05c0738111434d7e9 to your computer and use it in GitHub Desktop.
A QX with an exitcode
# Shamelessly nabbed from https://github.com/rakudo/rakudo/blob/master/src/core.c/Proc.pm6#L261-L265
sub myqx ($cmd, :$cwd = $*CWD, :$env) {
  my $proc := Proc.new(:out);
  $proc.shell($cmd, :$cwd, :$env);
 
  (
    $proc.out.slurp(:close) // Failure.new("Unable to read from '$cmd'"),
    $proc.exitcode
  )
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment