From: Dave Mitchell Date: Sun, 1 Feb 2004 17:42:44 +0000 (+0000) Subject: update fix to Shell.pm in change #22254: make /dev/null portable X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d0b4fbd9e2c9ee9a42f5c0de27ae9f61e9e33074;p=p5sagit%2Fp5-mst-13.2.git update fix to Shell.pm in change #22254: make /dev/null portable p4raw-link: @22254 on //depot/perl: c4a2e7a54bf494cff88f7c7c033f6b017d36f653 p4raw-id: //depot/perl@22259 --- diff --git a/lib/Shell.pm b/lib/Shell.pm index df2ae0a..83cc004 100644 --- a/lib/Shell.pm +++ b/lib/Shell.pm @@ -2,6 +2,8 @@ package Shell; use 5.006_001; use strict; use warnings; +use File::Spec::Functions; + our($capture_stderr, $VERSION, $AUTOLOAD); $VERSION = '0.5.1'; @@ -28,13 +30,14 @@ sub AUTOLOAD { shift if ref $_[0] && $_[0]->isa( 'Shell' ); my $cmd = $AUTOLOAD; $cmd =~ s/^.*:://; + my $null = File::Spec::Functions::devnull(); $Shell::capture_stderr ||= 0; eval <<"*END*"; sub $AUTOLOAD { shift if ref \$_[0] && \$_[0]->isa( 'Shell' ); if (\@_ < 1) { \$Shell::capture_stderr == 1 ? `$cmd 2>&1` : - \$Shell::capture_stderr == -1 ? `$cmd 2>/dev/null` : + \$Shell::capture_stderr == -1 ? `$cmd 2>$null` : `$cmd`; } elsif ('$^O' eq 'os2') { local(\*SAVEOUT, \*READ, \*WRITE); @@ -88,7 +91,7 @@ sub AUTOLOAD { } } push \@arr, '2>&1' if \$Shell::capture_stderr == 1; - push \@arr, '2>/dev/null' if \$Shell::capture_stderr == -1; + push \@arr, '2>$null' if \$Shell::capture_stderr == -1; open(SUBPROC, join(' ', '$cmd', \@arr, '|')) or die "Can't exec $cmd: \$!\\n"; if (wantarray) {