File: swallow_stderr.inc

package info (click to toggle)
libextutils-pkgconfig-perl 1.13-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 128 kB
  • sloc: perl: 163; ansic: 31; makefile: 2
file content (14 lines) | stat: -rw-r--r-- 233 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
sub swallow_stderr {
	my ($code) = @_;

	# We can't use the three-arg form with >& because perl 5.6 doesn't seem
	# to support that.
	open my $old_stderr, '>&STDERR';
	close STDERR;

	$code->();

	open STDERR, ">&$old_stderr";
}

1;