From: Martin Mares Date: Mon, 2 Jul 2012 14:09:18 +0000 (+0200) Subject: Update2: Remember original stdout X-Git-Tag: v1.0~1 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=2db624a1677436bb56bc6f9e710e3892a20ded68;p=git-tools.git Update2: Remember original stdout When called without --mailto, the message is printed to the standard output instead. --- diff --git a/update2 b/update2 index 46fc4c9..32426c8 100755 --- 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; }