In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/201e9e2aa1088e65b7160f94706673641f1e018a?hp=ba707cdc782d882662421af06658ff4afdf31003>
- Log ----------------------------------------------------------------- commit 201e9e2aa1088e65b7160f94706673641f1e018a Author: Tony Cook <[email protected]> Date: Tue Jun 23 10:21:45 2015 +1000 [perl #125373] set $! in chdir() if env not set, clarify docs ----------------------------------------------------------------------- Summary of changes: pod/perlfunc.pod | 4 ++-- pp_sys.c | 1 + t/op/chdir.t | 13 ++++++++----- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod index 650ad0e..a3f612d 100644 --- a/pod/perlfunc.pod +++ b/pod/perlfunc.pod @@ -825,8 +825,8 @@ X<directory, change> Changes the working directory to EXPR, if possible. If EXPR is omitted, changes to the directory specified by C<$ENV{HOME}>, if set; if not, changes to the directory specified by C<$ENV{LOGDIR}>. (Under VMS, the -variable C<$ENV{SYS$LOGIN}> is also checked, and used if it is set.) If -neither is set, C<chdir> does nothing. It returns true on success, +variable C<$ENV{'SYS$LOGIN'}> is also checked, and used if it is set.) If +neither is set, C<chdir> does nothing and fails. It returns true on success, false otherwise. See the example under C<die>. On systems that support fchdir(2), you may pass a filehandle or diff --git a/pp_sys.c b/pp_sys.c index da25f0f..b0f7798 100644 --- a/pp_sys.c +++ b/pp_sys.c @@ -3628,6 +3628,7 @@ PP(pp_chdir) } else { PUSHi(0); + SETERRNO(EINVAL, LIB_INVARG); TAINT_PROPER("chdir"); RETURN; } diff --git a/t/op/chdir.t b/t/op/chdir.t index 3a88f82..62ac3b6 100644 --- a/t/op/chdir.t +++ b/t/op/chdir.t @@ -10,11 +10,11 @@ BEGIN { # possibilities into @INC. unshift @INC, qw(t . lib ../lib); require "test.pl"; - plan(tests => 46); + plan(tests => 47); } use Config; -use Errno qw(ENOENT EBADF); +use Errno qw(ENOENT EBADF EINVAL); my $IsVMS = $^O eq 'VMS'; @@ -204,10 +204,13 @@ foreach my $key (@magic_envs) { { clean_env; - if ($IsVMS && !$Config{'d_setenv'}) { - pass("Can't reset HOME, so chdir() test meaningless"); - } else { + SKIP: + { + $IsVMS && !$Config{'d_setenv'} + and skip "Can't reset HOME, so chdir() test meaningless", 2; + $! = 0; ok( !chdir(), 'chdir() w/o any ENV set' ); + is( $!+0, EINVAL, 'check $! set to EINVAL'); } is( abs_path, $Cwd, ' abs_path() agrees' ); } -- Perl5 Master Repository
