Commit | Line | Data |
---|---|---|
61f2b451 | 1 | #!./perl |
2 | ||
7a4c00b4 | 3 | use Config; |
4 | ||
5 | BEGIN { | |
d846159b MS |
6 | if($ENV{PERL_CORE}) { |
7 | if ($Config{'extensions'} !~ /\bIO\b/) { | |
8 | print "1..0 # Skip: IO extension not compiled\n"; | |
7a4c00b4 | 9 | exit 0; |
10 | } | |
61f2b451 | 11 | } |
12 | } | |
13 | ||
14 | use IO::Handle; | |
15 | use IO::File; | |
16 | ||
17 | select(STDERR); $| = 1; | |
18 | select(STDOUT); $| = 1; | |
19 | ||
20 | print "1..6\n"; | |
21 | ||
22 | print "ok 1\n"; | |
23 | ||
24 | $dupout = IO::Handle->new->fdopen( \*STDOUT ,"w"); | |
25 | $duperr = IO::Handle->new->fdopen( \*STDERR ,"w"); | |
26 | ||
27 | $stdout = \*STDOUT; bless $stdout, "IO::File"; # "IO::Handle"; | |
28 | $stderr = \*STDERR; bless $stderr, "IO::Handle"; | |
29 | ||
30 | $stdout->open( "Io.dup","w") || die "Can't open stdout"; | |
31 | $stderr->fdopen($stdout,"w"); | |
32 | ||
33 | print $stdout "ok 2\n"; | |
34 | print $stderr "ok 3\n"; | |
ba553610 MS |
35 | |
36 | # Since some systems don't have echo, we use Perl. | |
e69a2255 | 37 | $echo = qq{$^X -le "print q(ok %d)"}; |
ba553610 MS |
38 | |
39 | $cmd = sprintf $echo, 4; | |
40 | print `$cmd`; | |
41 | ||
e69a2255 JH |
42 | $cmd = sprintf "$echo 1>&2", 5; |
43 | $cmd = sprintf $echo, 5 if $^O eq 'MacOS'; | |
ba553610 | 44 | print `$cmd`; |
61f2b451 | 45 | |
46 | $stderr->close; | |
47 | $stdout->close; | |
48 | ||
49 | $stdout->fdopen($dupout,"w"); | |
50 | $stderr->fdopen($duperr,"w"); | |
51 | ||
cda41bc1 | 52 | if ($^O eq 'MSWin32' || $^O eq 'NetWare' || $^O eq 'VMS') { print `type Io.dup` } |
e69a2255 JH |
53 | elsif ($^O eq 'MacOS') { system 'Catenate Io.dup' } |
54 | else { system 'cat Io.dup' } | |
61f2b451 | 55 | unlink 'Io.dup'; |
56 | ||
57 | print STDOUT "ok 6\n"; |