Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't push a directory named '0' #15

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions lib/File/pushd.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) = @_;
Expand All @@ -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;
Expand Down Expand Up @@ -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) = @_;
Expand Down Expand Up @@ -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} )
{
Expand Down
6 changes: 3 additions & 3 deletions t/File_pushd.t
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
18 changes: 18 additions & 0 deletions t/regressions/leading_zero.t
Original file line number Diff line number Diff line change
@@ -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;
1 change: 1 addition & 0 deletions tidyall.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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