9 # supress VMS whinging about bad execs.
10 use vmsish qw(hushed);
12 $| = 1; # flush stdout
14 $ENV{LC_ALL} = 'C'; # Forge English error messages.
15 $ENV{LANGUAGE} = 'C'; # Ditto in GNU.
19 my $Perl = which_perl();
23 skip("bug/feature of pdksh", 2) if $^O eq 'os2';
25 $exit = system qq{$Perl -le "print q{ok 1 - interpreted system(EXPR)"}};
27 is( $exit, 0, ' exited 0' );
30 $exit = system qq{$Perl -le "print q{ok 3 - split & direct call system(EXPR)"}};
32 is( $exit, 0, ' exited 0' );
34 # On VMS you need the quotes around the program or it won't work.
35 # On Unix its the opposite.
36 my $quote = $^O eq 'VMS' ? '"' : '';
37 $exit = system $Perl, '-le',
38 "${quote}print q{ok 5 - system(PROG, LIST)}${quote}";
40 is( $exit, 0, ' exited 0' );
43 is( system(qq{$Perl -e "exit 0"}), 0, 'Explicit exit of 0' );
45 my $exit_one = $^O eq 'VMS' ? 4 << 8 : 1 << 8;
46 is( system(qq{$Perl "-I../lib" -e "use vmsish qw(hushed); exit 1"}), $exit_one,
47 'Explicit exit of 1' );
50 $rc = system "lskdfj";
51 unless( ok($rc == 255 << 8 or $rc == -1 or $rc == 256) ) {
52 print "# \$rc == $rc\n";
55 unless ( ok( $! == 2 or $! =~ /\bno\b.*\bfile/i or
56 $! == 13 or $! =~ /permission denied/i or
57 $! == 22 or $! =~ /invalid argument/ ) ) {
58 printf "# \$! eq %d, '%s'\n", $!, $!;
62 is( `$Perl -le "print 'ok'"`, "ok\n", 'basic ``' );
63 is( <<`END`, "ok\n", '<<`HEREDOC`' );
64 $Perl -le "print 'ok'"
69 if( $^O =~ /Win32/ ) {
70 print "not ok 11 - exec failure doesn't terminate process # TODO Win32 exec failure waits for user input\n";
74 ok( !exec("lskdjfalksdjfdjfkls"),
75 "exec failure doesn't terminate process");
78 my $test = curr_test();
79 exec $Perl, '-le', qq{${quote}print 'ok $test - exec PROG, LIST'${quote}};
80 fail("This should never be reached if the exec() worked");