Created
May 13, 2015 18:28
-
-
Save dagolden/c5e560e5916bd9827b81 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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; | |
path($of)->spew($out); | |
path($ef)->spew($err); | |
exit( $rc & 255 ? 1 : $rc >> 8 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment