Skip to content

Commit

Permalink
[perl #125305] chdir("") no longer behaves like chdir()
Browse files Browse the repository at this point in the history
  • Loading branch information
tonycoz committed Jun 17, 2015
1 parent b6d5ddf commit b4929cb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 38 deletions.
10 changes: 0 additions & 10 deletions pod/perldiag.pod
Expand Up @@ -6658,16 +6658,6 @@ one. This doesn't make sense. Perl will continue, assuming a Unicode
happens to be ISO-8859-1 (Latin1) where this message is spurious and can
be ignored.

=item Use of chdir('') or chdir(undef) as chdir() deprecated

(D deprecated) chdir() with no arguments is documented to change to
$ENV{HOME} or $ENV{LOGDIR}. chdir(undef) and chdir('') share this
behavior, but that has been deprecated. In future versions they
will simply fail.

Be careful to check that what you pass to chdir() is defined and not
blank, else you might find yourself in your home directory.

=item Use of /c modifier is meaningless in s///

(W regexp) You used the /c modifier in a substitution. The /c
Expand Down
5 changes: 1 addition & 4 deletions pp_sys.c
Expand Up @@ -3591,8 +3591,7 @@ PP(pp_chdir)
else if (!(gv = MAYBE_DEREF_GV(sv)))
tmps = SvPV_nomg_const_nolen(sv);
}

if( !gv && (!tmps || !*tmps) ) {
else {
HV * const table = GvHVn(PL_envgv);
SV **svp;

Expand All @@ -3603,8 +3602,6 @@ PP(pp_chdir)
#endif
)
{
if( MAXARG == 1 )
deprecate("chdir('') or chdir(undef) as chdir()");
tmps = SvPV_nolen_const(*svp);
}
else {
Expand Down
30 changes: 6 additions & 24 deletions t/op/chdir.t
Expand Up @@ -10,10 +10,11 @@ BEGIN {
# possibilities into @INC.
unshift @INC, qw(t . lib ../lib);
require "./test.pl";
plan(tests => 48);
plan(tests => 42);
}

use Config;
use Errno qw(ENOENT);

my $IsVMS = $^O eq 'VMS';

Expand Down Expand Up @@ -150,29 +151,10 @@ sub check_env {

my $warning = '';
local $SIG{__WARN__} = sub { $warning .= join '', @_ };


# Check the deprecated chdir(undef) feature.
#line 64
ok( chdir(undef), "chdir(undef) w/ only \$ENV{$key} set" );
is( abs_path, $ENV{$key}, ' abs_path() agrees' );
is( $warning, <<WARNING, ' got uninit & deprecation warning' );
Use of uninitialized value in chdir at $0 line 64.
Use of chdir('') or chdir(undef) as chdir() is deprecated at $0 line 64.
WARNING

chdir($Cwd);

# Ditto chdir('').
$warning = '';
#line 76
ok( chdir(''), "chdir('') w/ only \$ENV{$key} set" );
is( abs_path, $ENV{$key}, ' abs_path() agrees' );
is( $warning, <<WARNING, ' got deprecation warning' );
Use of chdir('') or chdir(undef) as chdir() is deprecated at $0 line 76.
WARNING

chdir($Cwd);
$! = 0;
ok(!chdir(''), "chdir('') no longer implied chdir()");
is($!+0, ENOENT, 'check $! set appropriately');
is($warning, '', 'should no longer warn about deprecation');
}
}

Expand Down

0 comments on commit b4929cb

Please sign in to comment.