This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
af13d4d8f7e349ab1be0048353b5abfca152c4c6
[perl5.git] / t / io / dup.t
1 #!./perl
2
3 # $RCSfile: dup.t,v $$Revision: 4.1 $$Date: 92/08/07 18:27:27 $
4
5 print "1..6\n";
6
7 print "ok 1\n";
8
9 open(dupout,">&STDOUT");
10 open(duperr,">&STDERR");
11
12 open(STDOUT,">Io.dup") || die "Can't open stdout";
13 open(STDERR,">&STDOUT") || die "Can't open stderr";
14
15 select(STDERR); $| = 1;
16 select(STDOUT); $| = 1;
17
18 print STDOUT "ok 2\n";
19 print STDERR "ok 3\n";
20 if ($^O eq 'MSWin32') {
21     print `echo ok 4`;
22     print `echo ok 5 1>&2`; # does this work?
23 }
24 else {
25     system 'echo ok 4';
26     system 'echo ok 5 1>&2';
27 }
28
29 close(STDOUT);
30 close(STDERR);
31
32 open(STDOUT,">&dupout");
33 open(STDERR,">&duperr");
34
35 if ($^O eq 'MSWin32') { print `type Io.dup` }
36 else                  { system 'cat Io.dup' }
37 unlink 'Io.dup';
38
39 print STDOUT "ok 6\n";
40