xref: /openbsd-src/gnu/usr.bin/perl/t/lib/warnings/doio (revision 898184e3e61f9129feb5978fad5a8c6865f00b92)
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;
162no warnings 'io';
163-l STDIN;
164EXPECT
165Use of -l on filehandle STDIN at - line 3.
166########
167# doio.c [Perl_my_stat]
168use utf8;
169use open qw( :utf8 :std );
170use warnings 'io';
171-l ᶠᚻ;
172no warnings 'io';
173-l ᶠᚻ;
174EXPECT
175Use of -l on filehandle ᶠᚻ at - line 5.
176########
177# doio.c [Perl_do_aexec5]
178use warnings 'io' ;
179exec "lskdjfalksdjfdjfkls","" ;
180no warnings 'io' ;
181exec "lskdjfalksdjfdjfkls","" ;
182EXPECT
183OPTION regex
184Can't exec "lskdjfalksdjfdjfkls": .+
185########
186# doio.c [Perl_do_exec3]
187use warnings 'io' ;
188exec "lskdjfalksdjfdjfkls", "abc" ;
189no warnings 'io' ;
190exec "lskdjfalksdjfdjfkls", "abc" ;
191EXPECT
192OPTION regex
193Can't exec "lskdjfalksdjfdjfkls(:? abc)?": .+
194########
195# doio.c [win32_execvp]
196use warnings 'exec' ;
197exec $^X, "-e0" ;
198EXPECT
199########
200# doio.c [Perl_nextargv]
201$^W = 0 ;
202my $filename = "./temp.dir" ;
203mkdir $filename, 0777
204  or die "Cannot create directory $filename: $!\n" ;
205{
206    local (@ARGV) = ($filename) ;
207    local ($^I) = "" ;
208    my $x = <> ;
209}
210{
211    no warnings 'inplace' ;
212    local (@ARGV) = ($filename) ;
213    local ($^I) = "" ;
214    my $x = <> ;
215}
216{
217    use warnings 'inplace' ;
218    local (@ARGV) = ($filename) ;
219    local ($^I) = "" ;
220    my $x = <> ;
221}
222rmdir $filename ;
223EXPECT
224Can't do inplace edit: ./temp.dir is not a regular file at - line 9.
225Can't do inplace edit: ./temp.dir is not a regular file at - line 21.
226
227########
228# doio.c [Perl_do_eof]
229use warnings 'io' ;
230my $a = eof STDOUT ;
231no warnings 'io' ;
232$a = eof STDOUT ;
233EXPECT
234Filehandle STDOUT opened only for output at - line 3.
235########
236# doio.c [Perl_do_openn]
237use Config;
238BEGIN {
239    if ($Config{useperlio}) {
240	print <<EOM;
241SKIPPED
242# warns only without perlio
243EOM
244	exit;
245    }
246}
247use warnings 'io';
248my $x = "foo";
249open FOO, '>', \$x;
250open BAR, '>&', \*STDOUT; # should not warn
251no warnings 'io';
252open FOO, '>', \$x;
253EXPECT
254Can't open a reference at - line 14.
255########
256# doio.c [Perl_do_openn]
257use Config;
258BEGIN {
259    if (!$Config{useperlio}) {
260	print <<EOM;
261SKIPPED
262# warns only with perlio
263EOM
264	exit;
265    }
266}
267use warnings 'io' ;
268close STDOUT;
269open FH1, "../harness"; close FH1;
270no warnings 'io' ;
271open FH2, "../harness"; close FH2;
272EXPECT
273Filehandle STDOUT reopened as FH1 only for input at - line 14.
274########
275# doio.c [Perl_do_openn]
276use Config;
277use utf8;
278use open qw( :utf8 :std );
279BEGIN {
280    if (!$Config{useperlio}) {
281	print <<EOM;
282SKIPPED
283# warns only with perlio
284EOM
285	exit;
286    }
287}
288use warnings 'io' ;
289close STDOUT;
290open ᶠᚻ1, "../harness"; close ᶠᚻ1;
291no warnings 'io' ;
292open ᶠᚻ2, "../harness"; close ᶠᚻ2;
293EXPECT
294Filehandle STDOUT reopened as ᶠᚻ1 only for input at - line 16.
295########
296# doio.c [Perl_do_openn]
297use Config;
298BEGIN {
299    if (!$Config{useperlio}) {
300	print <<EOM;
301SKIPPED
302# warns only with perlio
303EOM
304	exit;
305    }
306}
307use warnings 'io' ;
308close STDIN;
309open my $fh1, ">doiowarn.tmp"; close $fh1;
310no warnings 'io' ;
311open my $fh2, ">doiowarn.tmp"; close $fh2;
312unlink "doiowarn.tmp";
313EXPECT
314Filehandle STDIN reopened as $fh1 only for output at - line 14.
315########
316# doio.c [Perl_do_openn]
317use Config;
318use utf8;
319use open qw( :utf8 :std );
320BEGIN {
321    if (!$Config{useperlio}) {
322	print <<EOM;
323SKIPPED
324# warns only with perlio
325EOM
326	exit;
327    }
328}
329use warnings 'io' ;
330close STDIN;
331open my $ᶠᚻ1, ">doiowarn.tmp"; close $ᶠᚻ1;
332no warnings 'io' ;
333open my $ᶠᚻ2, ">doiowarn.tmp"; close $ᶠᚻ2;
334unlink "doiowarn.tmp";
335EXPECT
336Filehandle STDIN reopened as $ᶠᚻ1 only for output at - line 16.
337########
338# doio.c [Perl_do_openn]
339use Config;
340use utf8;
341use open qw( :utf8 :std );
342BEGIN {
343    if (!$Config{useperlio}) {
344	print <<EOM;
345SKIPPED
346# warns only with perlio
347EOM
348	exit;
349    }
350}
351use warnings 'io' ;
352close STDIN;
353open ᶠᚻ1, ">doiowarn.tmp"; close ᶠᚻ1;
354no warnings 'io' ;
355open ᶠᚻ2, ">doiowarn.tmp"; close ᶠᚻ2;
356unlink "doiowarn.tmp";
357EXPECT
358Filehandle STDIN reopened as ᶠᚻ1 only for output at - line 16.
359