This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
additional docs and tests
[perl5.git] / t / op / exec.t
CommitLineData
8d063cd8
LW
1#!./perl
2
8d063cd8 3$| = 1; # flush stdout
68dc0745 4
9429f27a
JH
5$ENV{LC_ALL} = 'C'; # Forge English error messages.
6$ENV{LANGUAGE} = 'C'; # Ditto in GNU.
7
2986a63f 8if ($^O eq 'MSWin32' || $^O eq 'NetWare') {
1d3434b8 9 # XXX the system tests could be written to use ./perl and so work on Win32
45c0de28 10 print "1..0 # Skip: shh, win32\n";
68dc0745 11 exit(0);
12}
13
95e8664e
CN
14if ($^O eq 'MacOS') {
15 # XXX the system tests could be written to use ./perl and so work on Win32
16 print "1..0 # Mostly useless tests for Mac OS\n";
17 exit(0);
18}
19
378cc40b 20print "1..8\n";
8d063cd8 21
ec40c0cd
IZ
22if ($^O ne 'os2') {
23 print "not ok 1\n" if system "echo ok \\1"; # shell interpreted
24}
25else {
26 print "ok 1 # skipped: bug/feature of pdksh\n"; # shell interpreted
27}
378cc40b
LW
28print "not ok 2\n" if system "echo ok 2"; # split and directly called
29print "not ok 3\n" if system "echo", "ok", "3"; # directly called
8d063cd8 30
1d3434b8 31# these should probably be rewritten to match the examples in perlfunc.pod
378cc40b
LW
32if (system "true") {print "not ok 4\n";} else {print "ok 4\n";}
33
0994c4d0
JH
34if ($^O eq 'mpeix') {
35 print "ok 5 # skipped: status broken on MPE/iX\n";
36} else {
37 if ((system "/bin/sh -c 'exit 1'") != 256) { print "not "; }
38 print "ok 5\n";
39}
378cc40b 40
d5a9bfb0 41$rc = system "lskdfj";
9429f27a
JH
42if ($rc == 255 << 8 or $rc == -1 and
43 (
44 $! == 2 or
45 $! =~ /\bno\b.*\bfile/i or
46 $! == 13 or
47 $! =~ /permission denied/i
48 )
49 )
d5a9bfb0 50 {print "ok 6\n";} else {print "not ok 6\n";}
378cc40b
LW
51
52unless (exec "lskdjfalksdjfdjfkls") {print "ok 7\n";} else {print "not ok 7\n";}
53
54exec "echo","ok","8";