File: capture-stderr

package info (click to toggle)
ack-grep 1.80-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 680 kB
  • ctags: 161
  • sloc: perl: 4,715; ansic: 21; fortran: 11; makefile: 9
file content (13 lines) | stat: -rw-r--r-- 395 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
#! /usr/bin/perl
use strict;

# Untaint our arguments (we're very trusting):
my ($stderr)  = ((shift @ARGV) =~ /^(.+)$/s) or die 'No stderr';
my ($program) = ((shift @ARGV) =~ /^(.+)$/s) or die 'No program';

open(STDERR, '>', $stderr) or die "Can't redirect STDERR to $stderr: $!";

$0 = $program;
do $program;
die $@ if $@;
die "Couldn't run $program: $!"; # Ack doesn't return, it calls exit