From 2db624a1677436bb56bc6f9e710e3892a20ded68 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Mon, 2 Jul 2012 16:09:18 +0200 Subject: [PATCH] Update2: Remember original stdout When called without --mailto, the message is printed to the standard output instead. --- update2 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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; } -- 2.39.5