Skip to content

Commit b8fba97

Browse files
authored
[io grant] Point out my $*CWD = chdir … is an error
Will eventually write a separate paragraph on all the evils of $*CWD and link to it from all the problematic areas.
1 parent b78d4fd commit b8fba97

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

doc/Type/IO.pod6

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ By default, only C<:d> test is performed.
4040
chdir :r, :w '/tmp'; # … check its .r and .w are True
4141
chdir '/not-there'; # returns Failure
4242
43+
Note that the following construct is a mistake:
44+
45+
my $*CWD = chdir '/tmp/';
46+
47+
Use L«C<indir>|/routine/indir» instead.
48+
4349
=head2 sub &*chdir
4450
4551
Defined as:
@@ -63,6 +69,16 @@ to specify which file tests to perform.
6369
&*chdir('/tmp'); # change $*CWD and process's current directory to '/tmp'
6470
&*chdir('/not-there'); # returns Failure
6571
72+
Note that the following construct is a mistake:
73+
74+
my $*CWD = &*chdir('/tmp');
75+
76+
Use the following, instead; or see L«C<indir>|/routine/indir» if
77+
you do not need to change process's current directory:
78+
79+
temp $*CWD;
80+
&*chdir('/tmp');
81+
6682
=head2 sub indir
6783
6884
Defined as:

0 commit comments

Comments
 (0)