summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pod/perlfunc.pod4
-rw-r--r--pp_sys.c1
-rw-r--r--t/op/chdir.t13
3 files changed, 11 insertions, 7 deletions
diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod
index 650ad0e1ba..a3f612d39e 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 da25f0f41e..b0f7798007 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 3a88f8238b..62ac3b65a6 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' );
}