]> mj.ucw.cz Git - git-tools.git/commitdiff
Update2: Remember original stdout
authorMartin Mares <mj@ucw.cz>
Mon, 2 Jul 2012 14:09:18 +0000 (16:09 +0200)
committerMartin Mares <mj@ucw.cz>
Mon, 2 Jul 2012 14:09:18 +0000 (16:09 +0200)
When called without --mailto, the message is printed to the standard
output instead.

update2

diff --git a/update2 b/update2
index 46fc4c9f16f3a6619ae38388bc67c1a32db40f57..32426c897a1f3dfca1e874db2b7dc880a2ec6e45 100755 (executable)
--- a/update2
+++ b/update2
@@ -38,6 +38,7 @@ my $subj = '[' . $subject_prefix . ($ref eq 'master' ? '' : "/$ref") . ']';
 my $out = File::Temp->new() or die;
 my $outname = $out->filename;
 $out->autoflush(1);
+open ORIG_STDOUT, '>&', \*STDOUT;
 close STDOUT;
 open STDOUT, '>&', $out or die;
 
@@ -144,6 +145,7 @@ if (defined $mail_to) {
                '-s', $subj,
                $mail_to;
 } else {
-       print STDERR "Subject: $subj\n\n";
-       `cat >&2 $outname`;
+       open STDOUT, '>&', \*ORIG_STDOUT;
+       print "Subject: $subj\n\n";
+       system 'cat', $outname;
 }