xref: /openbsd-src/gnu/usr.bin/perl/t/lib/warnings/doio (revision 50b7afb2c2c0993b0894d4e34bf857cb13ed9c80)
1  doio.c
2
3  Can't open bidirectional pipe		[Perl_do_open9]
4    open(F, "| true |");
5
6  Missing command in piped open		[Perl_do_open9]
7    open(F, "| ");
8
9  Missing command in piped open		[Perl_do_open9]
10    open(F, " |");
11
12  warn(warn_nl, "open");		[Perl_do_open9]
13    open(F, "true\ncd")
14
15  close() on unopened filehandle %s	[Perl_do_close]
16    $a = "fred";close("$a")
17
18  tell() on closed filehandle		[Perl_do_tell]
19    $a = "fred";$a = tell($a)
20
21  seek() on closed filehandle		[Perl_do_seek]
22    $a = "fred";$a = seek($a,1,1)
23
24  sysseek() on closed filehandle	[Perl_do_sysseek]
25    $a = "fred";$a = seek($a,1,1)
26
27  warn(warn_uninit);			[Perl_do_print]
28    print $a ;
29
30  -x on closed filehandle %s 		[Perl_my_stat]
31    close STDIN ; -x STDIN ;
32
33  warn(warn_nl, "stat");		[Perl_my_stat]
34    stat "ab\ncd"
35
36  warn(warn_nl, "lstat");		[Perl_my_lstat]
37    lstat "ab\ncd"
38
39  Use of -l on filehandle %s		[Perl_my_lstat]
40
41  Can't exec \"%s\": %s 		[Perl_do_aexec5]
42
43  Can't exec \"%s\": %s 		[Perl_do_exec3]
44
45  Filehandle %s opened only for output	[Perl_do_eof]
46	my $a = eof STDOUT
47
48  Mandatory Warnings ALL TODO
49  ------------------
50  Can't do inplace edit: %s is not a regular file	[Perl_nextargv]
51     edit a directory
52
53  Can't do inplace edit: %s would not be unique		[Perl_nextargv]
54  Can't rename %s to %s: %s, skipping file		[Perl_nextargv]
55  Can't rename %s to %s: %s, skipping file		[Perl_nextargv]
56  Can't remove %s: %s, skipping file			[Perl_nextargv]
57  Can't do inplace edit on %s: %s			[Perl_nextargv]
58
59
60__END__
61# doio.c [Perl_do_open9]
62use warnings 'io' ;
63open(F, '|'."$^X -e 1|");
64close(F);
65no warnings 'io' ;
66open(G, '|'."$^X -e 1|");
67close(G);
68EXPECT
69Can't open bidirectional pipe at - line 3.
70########
71# doio.c [Perl_do_open9]
72use warnings 'io' ;
73open(F, "|      ");
74no warnings 'io' ;
75open(G, "|      ");
76EXPECT
77Missing command in piped open at - line 3.
78########
79# doio.c [Perl_do_open9]
80use warnings 'io' ;
81open(F, "      |");
82no warnings 'io' ;
83open(G, "      |");
84EXPECT
85Missing command in piped open at - line 3.
86########
87# doio.c [Perl_do_open9]
88use warnings 'io' ;
89open(F, "<true\ncd");
90no warnings 'io' ;
91open(G, "<true\ncd");
92EXPECT
93Unsuccessful open on filename containing newline at - line 3.
94########
95# doio.c [Perl_do_close] <<TODO
96use warnings 'unopened' ;
97close "fred" ;
98no warnings 'unopened' ;
99close "joe" ;
100EXPECT
101close() on unopened filehandle fred at - line 3.
102########
103# doio.c [Perl_do_tell Perl_do_seek Perl_do_sysseek Perl_my_stat]
104use warnings 'io' ;
105close STDIN ;
106tell(STDIN);
107$a = seek(STDIN,1,1);
108$a = sysseek(STDIN,1,1);
109-x STDIN ;
110stat(STDIN) ;
111$a = "fred";
112tell($a);
113seek($a,1,1);
114sysseek($a,1,1);
115-x $a; # ok
116stat($a); # ok
117no warnings 'io' ;
118close STDIN ;
119tell(STDIN);
120$a = seek(STDIN,1,1);
121$a = sysseek(STDIN,1,1);
122-x STDIN ;
123stat(STDIN) ;
124$a = "fred";
125tell($a);
126seek($a,1,1);
127sysseek($a,1,1);
128-x $a;
129stat($a);
130EXPECT
131tell() on closed filehandle STDIN at - line 4.
132seek() on closed filehandle STDIN at - line 5.
133sysseek() on closed filehandle STDIN at - line 6.
134-x on closed filehandle STDIN at - line 7.
135stat() on closed filehandle STDIN at - line 8.
136tell() on unopened filehandle at - line 10.
137seek() on unopened filehandle at - line 11.
138sysseek() on unopened filehandle at - line 12.
139########
140# doio.c [Perl_do_print]
141use warnings 'uninitialized' ;
142print $a ;
143no warnings 'uninitialized' ;
144print $b ;
145EXPECT
146Use of uninitialized value $a in print at - line 3.
147########
148# doio.c [Perl_my_stat Perl_my_lstat]
149use warnings 'io' ;
150stat "ab\ncd";
151lstat "ab\ncd";
152no warnings 'io' ;
153stat "ab\ncd";
154lstat "ab\ncd";
155EXPECT
156Unsuccessful stat on filename containing newline at - line 3.
157Unsuccessful stat on filename containing newline at - line 4.
158########
159# doio.c [Perl_my_stat]
160use warnings 'io';
161-l STDIN;
162-l $fh;
163open $fh, $0 or die "# $!";
164-l $fh;
165no warnings 'io';
166-l STDIN;
167-l $fh;
168close $fh;
169EXPECT
170Use of -l on filehandle STDIN at - line 3.
171Use of -l on filehandle $fh at - line 6.
172########
173# doio.c [Perl_my_stat]
174use utf8;
175use open qw( :utf8 :std );
176use warnings 'io';
177-l ᶠᚻ;
178no warnings 'io';
179-l ᶠᚻ;
180EXPECT
181Use of -l on filehandle ᶠᚻ at - line 5.
182########
183# doio.c [Perl_do_aexec5]
184use warnings 'io' ;
185exec "lskdjfalksdjfdjfkls","" ;
186no warnings 'io' ;
187exec "lskdjfalksdjfdjfkls","" ;
188EXPECT
189OPTION regex
190Can't exec "lskdjfalksdjfdjfkls": .+
191########
192# doio.c [Perl_do_exec3]
193use warnings 'io' ;
194exec "lskdjfalksdjfdjfkls", "abc" ;
195no warnings 'io' ;
196exec "lskdjfalksdjfdjfkls", "abc" ;
197EXPECT
198OPTION regex
199Can't exec "lskdjfalksdjfdjfkls(:? abc)?": .+
200########
201# doio.c [win32_execvp]
202use warnings 'exec' ;
203exec $^X, "-e0" ;
204EXPECT
205########
206# doio.c [Perl_nextargv]
207$^W = 0 ;
208my $filename = "./temp.dir" ;
209mkdir $filename, 0777
210  or die "Cannot create directory $filename: $!\n" ;
211{
212    local (@ARGV) = ($filename) ;
213    local ($^I) = "" ;
214    my $x = <> ;
215}
216{
217    no warnings 'inplace' ;
218    local (@ARGV) = ($filename) ;
219    local ($^I) = "" ;
220    my $x = <> ;
221}
222{
223    use warnings 'inplace' ;
224    local (@ARGV) = ($filename) ;
225    local ($^I) = "" ;
226    my $x = <> ;
227}
228rmdir $filename ;
229EXPECT
230Can't do inplace edit: ./temp.dir is not a regular file at - line 9.
231Can't do inplace edit: ./temp.dir is not a regular file at - line 21.
232
233########
234# doio.c [Perl_do_eof]
235use warnings 'io' ;
236my $a = eof STDOUT ;
237no warnings 'io' ;
238$a = eof STDOUT ;
239EXPECT
240Filehandle STDOUT opened only for output at - line 3.
241########
242# doio.c [Perl_do_openn]
243use Config;
244BEGIN {
245    if ($Config{useperlio}) {
246	print <<EOM;
247SKIPPED
248# warns only without perlio
249EOM
250	exit;
251    }
252}
253use warnings 'io';
254my $x = "foo";
255open FOO, '>', \$x;
256open BAR, '>&', \*STDOUT; # should not warn
257no warnings 'io';
258open FOO, '>', \$x;
259EXPECT
260Can't open a reference at - line 14.
261########
262# doio.c [Perl_do_openn]
263use Config;
264BEGIN {
265    if (!$Config{useperlio}) {
266	print <<EOM;
267SKIPPED
268# warns only with perlio
269EOM
270	exit;
271    }
272}
273use warnings 'io' ;
274close STDOUT;
275open FH1, "../harness"; close FH1;
276no warnings 'io' ;
277open FH2, "../harness"; close FH2;
278EXPECT
279Filehandle STDOUT reopened as FH1 only for input at - line 14.
280########
281# doio.c [Perl_do_openn]
282use Config;
283use utf8;
284use open qw( :utf8 :std );
285BEGIN {
286    if (!$Config{useperlio}) {
287	print <<EOM;
288SKIPPED
289# warns only with perlio
290EOM
291	exit;
292    }
293}
294use warnings 'io' ;
295close STDOUT;
296open ᶠᚻ1, "../harness"; close ᶠᚻ1;
297no warnings 'io' ;
298open ᶠᚻ2, "../harness"; close ᶠᚻ2;
299EXPECT
300Filehandle STDOUT reopened as ᶠᚻ1 only for input at - line 16.
301########
302# doio.c [Perl_do_openn]
303use Config;
304BEGIN {
305    if (!$Config{useperlio}) {
306	print <<EOM;
307SKIPPED
308# warns only with perlio
309EOM
310	exit;
311    }
312}
313use warnings 'io' ;
314close STDIN;
315open my $fh1, ">doiowarn.tmp"; close $fh1;
316no warnings 'io' ;
317open my $fh2, ">doiowarn.tmp"; close $fh2;
318unlink "doiowarn.tmp";
319EXPECT
320Filehandle STDIN reopened as $fh1 only for output at - line 14.
321########
322# doio.c [Perl_do_openn]
323use Config;
324use utf8;
325use open qw( :utf8 :std );
326BEGIN {
327    if (!$Config{useperlio}) {
328	print <<EOM;
329SKIPPED
330# warns only with perlio
331EOM
332	exit;
333    }
334}
335use warnings 'io' ;
336close STDIN;
337open my $ᶠᚻ1, ">doiowarn.tmp"; close $ᶠᚻ1;
338no warnings 'io' ;
339open my $ᶠᚻ2, ">doiowarn.tmp"; close $ᶠᚻ2;
340unlink "doiowarn.tmp";
341EXPECT
342Filehandle STDIN reopened as $ᶠᚻ1 only for output at - line 16.
343########
344# doio.c [Perl_do_openn]
345use Config;
346use utf8;
347use open qw( :utf8 :std );
348BEGIN {
349    if (!$Config{useperlio}) {
350	print <<EOM;
351SKIPPED
352# warns only with perlio
353EOM
354	exit;
355    }
356}
357use warnings 'io' ;
358close STDIN;
359open ᶠᚻ1, ">doiowarn.tmp"; close ᶠᚻ1;
360no warnings 'io' ;
361open ᶠᚻ2, ">doiowarn.tmp"; close ᶠᚻ2;
362unlink "doiowarn.tmp";
363EXPECT
364Filehandle STDIN reopened as ᶠᚻ1 only for output at - line 16.
365