]> git.pld-linux.org Git - packages/rpm-build-tools.git/blobdiff - teeboth
Release 2 (by relup.sh)
[packages/rpm-build-tools.git] / teeboth
diff --git a/teeboth b/teeboth
index b30e92c01203a431c309a51c778f6ac49a4c24bb..459e0c888e4b1b563bfe10a844fd72ed4bad723a 100755 (executable)
--- a/teeboth
+++ b/teeboth
@@ -11,11 +11,12 @@ use IO::Select;
 my $out = shift @ARGV;
 die unless @ARGV;
 
-open my $fout, ">", $out or die;
+open my $fout, ">>", $out or die "Can't write to $out: $!" if $out;
 
 my $select = IO::Select->new();
 my $alive = 1;
 my $pid;
+my $interactive = -t STDOUT;
 
 my $code;
 sub sigchld
@@ -31,8 +32,7 @@ sub sigchld
 }
 $SIG{CHLD} = \&sigchld;
 
-$pid = open3( \*child_in, \*child_out, \*child_err, @ARGV );
-close child_in;
+$pid = open3( "<&STDIN",  \*child_out, \*child_err, @ARGV );
 
 sub sethandle
 {
@@ -44,7 +44,7 @@ sub sethandle
        $flags |= O_NONBLOCK;
        fcntl ( $h, F_SETFL, $flags )
                or die "Couldn't set flags for HANDLE: $!\n";
-       
+
        $select->add( $h );
 }
 
@@ -53,9 +53,9 @@ sethandle( \*child_err );
 
 while ( $alive ) {
        foreach my $h ( $select->can_read() ) {
-               sysread $h, $_, 1024;
-               print $fout $_;
-               if ( $h == \*child_err ) {
+               sysread $h, $_, 102400;
+               print $fout $_ if $fout;
+               if ( $interactive && $h == \*child_err ) {
                        print "\033[31m$_\033[0m";
                } else {
                        print $_;
This page took 0.040722 seconds and 4 git commands to generate.