Skip to content

Instantly share code, notes, and snippets.

Created May 13, 2015
What would you like to do?
#!/usr/bin/env perl
use v5.10;
use strict;
use warnings;
use Capture::Tiny 'tee';
use Path::Tiny;
die "Usage: $0 <outfile> <errfile> <command ...>\n"
unless @ARGV > 2;
my ($of, $ef, @cmd) = @ARGV;
my ($out, $err, $rc) = tee { system(@cmd) };
die "Error executing '@cmd': $!" if $rc < 0;
exit( $rc & 255 ? 1 : $rc >> 8 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment