summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManuel Valente <mvalente@idealx.com>2004-01-27 20:18:26 +0100
committerDave Mitchell <davem@fdisolutions.com>2004-02-01 13:11:00 +0000
commitc4a2e7a54bf494cff88f7c7c033f6b017d36f653 (patch)
tree1dd6df9f7eb6c94ad0b3fa076e3f5df916c14ec1
parentb4c5c611165551aaef8a59a0e287e0f18687668b (diff)
downloadperl-c4a2e7a54bf494cff88f7c7c033f6b017d36f653.tar.gz
Patch for Shell.pm
Message-Id: <4016AB72.1080503@idealx.com> New option for Shell.pm to discard stderr instead of capturing it p4raw-id: //depot/perl@22254
-rw-r--r--lib/Shell.pm13
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/Shell.pm b/lib/Shell.pm
index e300d792c6..7618cc1e41 100644
--- a/lib/Shell.pm
+++ b/lib/Shell.pm
@@ -4,7 +4,7 @@ use strict;
use warnings;
our($capture_stderr, $VERSION, $AUTOLOAD);
-$VERSION = '0.5';
+$VERSION = '0.5.1';
sub new { bless \my $foo, shift }
sub DESTROY { }
@@ -28,11 +28,14 @@ sub AUTOLOAD {
shift if ref $_[0] && $_[0]->isa( 'Shell' );
my $cmd = $AUTOLOAD;
$cmd =~ s/^.*:://;
+ $Shell::capture_stderr ||= 0;
eval <<"*END*";
sub $AUTOLOAD {
shift if ref \$_[0] && \$_[0]->isa( 'Shell' );
if (\@_ < 1) {
- \$Shell::capture_stderr ? `$cmd 2>&1` : `$cmd`;
+ \$Shell::capture_stderr == 1 ? `$cmd 2>&1` :
+ \$Shell::capture_stderr == -1 ? `$cmd 2>/dev/null` :
+ `$cmd`;
} elsif ('$^O' eq 'os2') {
local(\*SAVEOUT, \*READ, \*WRITE);
@@ -84,7 +87,8 @@ sub AUTOLOAD {
\$_ = \$_;
}
}
- push \@arr, '2>&1' if \$Shell::capture_stderr;
+ push \@arr, '2>&1' if \$Shell::capture_stderr == 1;
+ push \@arr, '2>/dev/null' if \$Shell::capture_stderr == -1;
open(SUBPROC, join(' ', '$cmd', \@arr, '|'))
or die "Can't exec $cmd: \$!\\n";
if (wantarray) {
@@ -154,6 +158,9 @@ Larry
If you set $Shell::capture_stderr to 1, the module will attempt to
capture the STDERR of the process as well.
+If you set $Shell::capture_stderr to -1, the module will discard the
+STDERR of the process.
+
The module now should work on Win32.
Jenda