Skip to content

Commit abc8076

Browse files
gemmaromquinson
authored andcommitted
Utilize File::Spec for /dev/null file path.
1 parent da27b0e commit abc8076

File tree

4 files changed

+15
-9
lines changed

4 files changed

+15
-9
lines changed

Po4aBuilder.pm

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,10 @@ sub ACTION_man {
240240
$command = "msggrep -K -E -e \"Po4a Tools\" po/pod/$lang.po |";
241241
$command .= "msgconv -t UTF-8 | ";
242242
$command .= "msgexec /bin/sh -c '[ -n \"\$MSGEXEC_MSGID\" ] ";
243-
$command .= "&& cat || cat > /dev/null'";
243+
my $devnull = File::Spec->devnull;
244+
$command .= "&& cat || cat > $devnull'";
244245

245-
my $title = `$command 2> /dev/null`;
246+
my $title = `$command 2> $devnull`;
246247
$title = "Po4a Tools" unless length $title;
247248
$title = Encode::decode_utf8($title);
248249
$parser->{release} = $parser->{center} = $title;
@@ -313,8 +314,9 @@ sub postats {
313314
my ( @t100, @t95, @t90, @t80, @t70, @t50, @t33, @t20, @starting );
314315

315316
foreach my $file ( sort @files ) {
316-
my $lang = fileparse( $file, qw{.po} );
317-
my $stat = `msgfmt -o /dev/null -c --statistics $file 2>&1`;
317+
my $lang = fileparse( $file, qw{.po} );
318+
my $devnull = File::Spec->devnull;
319+
my $stat = `msgfmt -o $devnull -c --statistics $file 2>&1`;
318320
my ( $trans, $fuzz, $untr ) = ( 0, 0, 0 );
319321
if ( $stat =~ /(\d+)\D+?(\d+)\D+?(\d+)/ ) {
320322
( $trans, $fuzz, $untr ) = ( $1, $2, $3 );

lib/Locale/Po4a/Po.pm

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ use Carp qw(croak);
115115
use File::Basename;
116116
use File::Path; # mkdir before write
117117
use File::Copy; # move
118-
use POSIX qw(strftime floor);
118+
use File::Spec qw();
119+
use POSIX qw(strftime floor);
119120
use Time::Local;
120121

121122
use Encode;
@@ -322,7 +323,8 @@ sub read {
322323
$self->{lang} = $lang;
323324

324325
if ($checkvalidity) { # We sometimes need to read a file even if it may be invalid (eg to test whether it's empty)
325-
my $cmd = "msgfmt" . $Config{_exe} . " --check-format --check-domain -o /dev/null \"" . $filename . '"';
326+
my $devnull = File::Spec->devnull;
327+
my $cmd = "msgfmt" . $Config{_exe} . " --check-format --check-domain -o $devnull \"" . $filename . '"';
326328

327329
my $locale = $ENV{'LC_ALL'};
328330
$ENV{'LC_ALL'} = "C";

lib/Locale/Po4a/Sgml.pm

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,8 @@ use warnings;
212212

213213
use parent qw(Locale::Po4a::TransTractor);
214214

215+
use File::Spec qw();
216+
215217
use Locale::Po4a::Common qw(wrap_mod wrap_ref_mod dgettext);
216218

217219
eval qq{use SGMLS};
@@ -861,7 +863,8 @@ sub parse_file {
861863
print $tmpfh $origfile;
862864
close $tmpfh or die wrap_mod( "po4a::sgml", dgettext( "po4a", "Cannot close tempfile: %s" ), $! );
863865

864-
my $cmd = "onsgmls -l -E 0 -wno-valid $tmpfile" . ( $debug{'onsgmls'} ? "" : " 2>/dev/null" ) . " |";
866+
my $devnull = File::Spec->devnull;
867+
my $cmd = "onsgmls -l -E 0 -wno-valid $tmpfile" . ( $debug{'onsgmls'} ? "" : " 2>$devnull" ) . " |";
865868
print STDERR "CMD=$cmd\n" if ( $debug{'generic'} or $debug{'onsgmls'} );
866869

867870
open( IN, $cmd ) || die wrap_mod( "po4a::sgml", dgettext( "po4a", "Cannot run onsgmls: %s" ), $! );

po4a

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -845,8 +845,7 @@ sub show_version {
845845
# keep the command line arguments
846846
my @ORIGINAL_ARGV = @ARGV;
847847

848-
# Use /NUL instead of /dev/null on Windows
849-
my $devnull = ( $^O =~ /Win/ ) ? '/NUL' : '/dev/null';
848+
my $devnull = File::Spec->devnull;
850849

851850
# Parse the options provided on the command line, or in argument
852851
sub get_options {

0 commit comments

Comments
 (0)