Commit | Line | Data |
378cc40b |
1 | #!./perl |
2 | |
ba553610 |
3 | BEGIN { |
4 | chdir 't' if -d 't'; |
5 | @INC = '../lib'; |
6 | } |
378cc40b |
7 | |
ba553610 |
8 | my $test = 1; |
e4a4387c |
9 | print "1..8\n"; |
378cc40b |
10 | print "ok 1\n"; |
11 | |
ba553610 |
12 | open(DUPOUT,">&STDOUT"); |
13 | open(DUPERR,">&STDERR"); |
378cc40b |
14 | |
ba553610 |
15 | open(STDOUT,">Io.dup") || die "Can't open stdout"; |
a687059c |
16 | open(STDERR,">&STDOUT") || die "Can't open stderr"; |
378cc40b |
17 | |
a687059c |
18 | select(STDERR); $| = 1; |
19 | select(STDOUT); $| = 1; |
378cc40b |
20 | |
a687059c |
21 | print STDOUT "ok 2\n"; |
22 | print STDERR "ok 3\n"; |
ba553610 |
23 | |
24 | # Since some systems don't have echo, we use Perl. |
25 | $echo = qq{$^X -le "print q{ok %d}"}; |
26 | |
27 | $cmd = sprintf $echo, 4; |
28 | print `$cmd`; |
29 | |
30 | $cmd = sprintf "$echo 1>&2", 5; |
31 | print `$cmd`; |
32 | |
33 | # KNOWN BUG system() does not honor STDOUT redirections on VMS. |
34 | if( $^O eq 'VMS' ) { |
35 | print "not ok $_ # TODO system() not honoring STDOUT redirect on VMS\n" |
36 | for 6..7; |
37 | } |
38 | else { |
39 | system sprintf $echo, 6; |
40 | system sprintf "$echo 1>&2", 7; |
41 | } |
378cc40b |
42 | |
d1e4d418 |
43 | close(STDOUT) or die "Could not close: $!"; |
44 | close(STDERR) or die "Could not close: $!"; |
378cc40b |
45 | |
d1e4d418 |
46 | open(STDOUT,">&DUPOUT") or die "Could not open: $!"; |
47 | open(STDERR,">&DUPERR") or die "Could not open: $!"; |
378cc40b |
48 | |
cda41bc1 |
49 | if (($^O eq 'MSWin32') || ($^O eq 'NetWare') || ($^O eq 'VMS')) { print `type Io.dup` } |
68dc0745 |
50 | else { system 'cat Io.dup' } |
378cc40b |
51 | unlink 'Io.dup'; |
52 | |
e4a4387c |
53 | print STDOUT "ok 8\n"; |
9394203c |
54 | |