From fd5879b01ec9322f3e23f9313ca89d86144525f5 Mon Sep 17 00:00:00 2001 From: Diab Jerius Date: Tue, 22 Jan 2019 16:33:57 -0500 Subject: [PATCH 1/4] make tidyall use .perltidyrc in current directory --- tidyall.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/tidyall.ini b/tidyall.ini index 91aa246..e540a06 100644 --- a/tidyall.ini +++ b/tidyall.ini @@ -3,3 +3,4 @@ ; run "tidyall -g" to tidy only files modified from git [PerlTidy] select = {lib,t}/**/*.{pl,pm,t} +argv = --profile=$ROOT/.perltidyrc From 309baf66cb9a0334f9427dac3b9315ab9856fae1 Mon Sep 17 00:00:00 2001 From: Diab Jerius Date: Tue, 22 Jan 2019 16:43:55 -0500 Subject: [PATCH 2/4] tidy code --- lib/File/pushd.pm | 14 +++++++------- t/File_pushd.t | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/File/pushd.pm b/lib/File/pushd.pm index c51be98..cc769d5 100644 --- a/lib/File/pushd.pm +++ b/lib/File/pushd.pm @@ -26,9 +26,9 @@ use overload sub pushd { # Called in void context? - unless (defined wantarray) { - warnings::warnif(void => 'Useless use of File::pushd::pushd in void context'); - return + unless ( defined wantarray ) { + warnings::warnif( void => 'Useless use of File::pushd::pushd in void context' ); + return; } my ( $target_dir, $options ) = @_; @@ -77,9 +77,9 @@ sub pushd { sub tempd { # Called in void context? - unless (defined wantarray) { - warnings::warnif(void => 'Useless use of File::pushd::tempd in void context'); - return + unless ( defined wantarray ) { + warnings::warnif( void => 'Useless use of File::pushd::tempd in void context' ); + return; } my ($options) = @_; @@ -116,7 +116,7 @@ sub DESTROY { my ($self) = @_; my $orig = $self->{_original}; chdir $orig if $orig; # should always be so, but just in case... - if ( $self->{_tempd} + if ( $self->{_tempd} && $self->{_owner} == $$ && !$self->{_preserve} ) { diff --git a/t/File_pushd.t b/t/File_pushd.t index 049f91e..8f0a2aa 100644 --- a/t/File_pushd.t +++ b/t/File_pushd.t @@ -230,11 +230,11 @@ ok( -e $expected_dir, "original directory not removed" ); # Test removing temp directory by owner process #--------------------------------------------------------------------------# if ( $Config{d_fork} ) { - my $new_dir = tempd(); + my $new_dir = tempd(); my $temp_dir = "$new_dir"; - my $pid = fork; + my $pid = fork; die "Can't fork: $!" unless defined $pid; - if ($pid == 0) { + if ( $pid == 0 ) { exit; } wait; From daacd574744c2d2f3cd5ca03aa5bbd9b87565e4e Mon Sep 17 00:00:00 2001 From: Diab Jerius Date: Tue, 22 Jan 2019 16:35:36 -0500 Subject: [PATCH 3/4] check regression for directory with a leading 0 --- t/regressions/leading_zero.t | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 t/regressions/leading_zero.t diff --git a/t/regressions/leading_zero.t b/t/regressions/leading_zero.t new file mode 100644 index 0000000..f7c5f66 --- /dev/null +++ b/t/regressions/leading_zero.t @@ -0,0 +1,18 @@ +use strict; +use warnings; +use Test::More 0.96; +use File::pushd; +use Cwd; +use File::Spec::Functions 'catdir'; + +{ + my $temp = tempd(); + mkdir '0' or die("unable to create 0 directory\n"); + + my $parent = "$temp"; + my $child = pushd('0'); + + is( "$child", catdir( "$parent", '0' ) ); +} + +done_testing; From bbbb222161d62d6bb9dc1a644955abd32fd9a1c3 Mon Sep 17 00:00:00 2001 From: Diab Jerius Date: Tue, 22 Jan 2019 16:41:38 -0500 Subject: [PATCH 4/4] checked truthfulness of $target_dir instead of whether it was defined --- lib/File/pushd.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/File/pushd.pm b/lib/File/pushd.pm index cc769d5..a43fbe7 100644 --- a/lib/File/pushd.pm +++ b/lib/File/pushd.pm @@ -47,7 +47,7 @@ sub pushd { } my $tainted_dest; - eval { $tainted_dest = $target_dir ? abs_path($target_dir) : $orig }; + eval { $tainted_dest = defined $target_dir ? abs_path($target_dir) : $orig }; croak "Can't locate absolute path for $target_dir: $@" if $@; my $dest;