@@ -52,20 +52,29 @@ sub run_perlpp {
52
52
# do { (my $args = Dumper($lrArgs)) =~ s/^/##/gm;
53
53
# say STDERR "## args:\n$args"; };
54
54
55
- if ($ENV {PERLPP_PERLOPTS }) {
56
- # my $cmd = join(' ', get_perl_filename(), $ENV{PERLPP_PERLOPTS},
57
- # @$lrArgs);
58
- my $cmd = [get_perl_filename(), shellwords($ENV {PERLPP_PERLOPTS }),
59
- @$lrArgs ];
55
+ if ($ENV {PERLPP_PERLOPTS }) { # Run external perl
56
+ state $printed_perl ;
57
+
58
+ my $perl = get_perl_filename();
59
+ BAIL_OUT(" Cannot find executable perl (tried $perl )" ) unless -x $perl ;
60
+
61
+ unless ($printed_perl ) { # Report it once for the sake of the logs
62
+ say STDERR " # External perl: {$perl }" ;
63
+ $printed_perl = 1;
64
+ }
65
+
66
+ my $cmd = [$perl , shellwords($ENV {PERLPP_PERLOPTS }), @$lrArgs ];
67
+
60
68
# say STDERR '# running external perl: {', join('|',@$cmd), '}';
61
69
$retval = run3($cmd , $refStdin , $refStdout , $refStderr );
62
70
# say STDERR "# returned $retval; status $?";
71
+
63
72
# TODO figure out $?, retval, &c.
64
73
# TODO tell the caller if the user hit Ctl-C on the inner perl
65
74
# invocation so the caller can abort if desired.
66
75
# That seems to be status 2, on my test system.
67
76
68
- } else {
77
+ } else { # Run perl code under this perl
69
78
# say STDERR "# running perlpp internal";
70
79
# say STDERR "# redirecting stdin";
71
80
open local (*STDIN ), ' <' , $refStdin or die $! ;
@@ -90,12 +99,16 @@ sub run_perlpp {
90
99
return $retval ;
91
100
} # run_perlpp
92
101
93
- # Get the filename of the Perl interpreter running this. From perlvar.
102
+ # Get the filename of the Perl interpreter running this. Modified from perlvar.
103
+ # The -x test is for cygwin or other systems where $Config{perlpath} has no
104
+ # extension and $Config{_exe} is nonempty. E.g., symlink perl->perl5.10.1.exe.
105
+ # There is no "perl.exe" on such a system.
94
106
sub get_perl_filename {
95
107
my $secure_perl_path = $Config {perlpath };
96
108
if ($^O ne ' VMS' ) {
97
109
$secure_perl_path .= $Config {_exe }
98
- unless $secure_perl_path =~ m /$Config {_exe}$ / i ;
110
+ unless (-x $secure_perl_path ) ||
111
+ ($secure_perl_path =~ m /$Config {_exe}$ / i );
99
112
}
100
113
return $secure_perl_path ;
101
114
} # get_perl_filename()
0 commit comments