I wrote:

>The other problem is that I cannot Do The Right Thing while keeping
>the current API intact. I propose the attached patch as an alternative,

Stop the press! My patch was incomplete: I forgot to rename
"rewrite_shebang()" into "shebang_to_perl()" in subclasses
ModPerl::Registry and ModPerl::PerlRun. Here is an updated patch.

Index: ModPerl-Registry/lib/ModPerl/PerlRun.pm
===================================================================
--- ModPerl-Registry/lib/ModPerl/PerlRun.pm     (revision 158046)
+++ ModPerl-Registry/lib/ModPerl/PerlRun.pm     (working copy)
@@ -50,7 +50,7 @@
     cache_table     => 'cache_table_common',
     cache_it        => 'NOP',
     read_script     => 'read_script',
-    rewrite_shebang => 'rewrite_shebang',
+    shebang_to_perl => 'shebang_to_perl',
     get_script_name => 'get_script_name',
     chdir_file      => 'chdir_file_normal',
     get_mark_line   => 'get_mark_line',
Index: ModPerl-Registry/lib/ModPerl/Registry.pm
===================================================================
--- ModPerl-Registry/lib/ModPerl/Registry.pm    (revision 158046)
+++ ModPerl-Registry/lib/ModPerl/Registry.pm    (working copy)
@@ -50,7 +50,7 @@
     cache_table     => 'cache_table_common',
     cache_it        => 'cache_it',
     read_script     => 'read_script',
-    rewrite_shebang => 'rewrite_shebang',
+    shebang_to_perl => 'shebang_to_perl',
     get_script_name => 'get_script_name',
     chdir_file      => 'chdir_file_normal',
     get_mark_line   => 'get_mark_line',
Index: ModPerl-Registry/lib/ModPerl/RegistryCooker.pm
===================================================================
--- ModPerl-Registry/lib/ModPerl/RegistryCooker.pm      (revision 158046)
+++ ModPerl-Registry/lib/ModPerl/RegistryCooker.pm      (working copy)
@@ -371,7 +371,7 @@
     return $rc unless $rc == Apache::OK;
 
     # convert the shebang line opts into perl code
-    $self->rewrite_shebang;
+       my $shebang = $self->shebang_to_perl;
 
     # mod_cgi compat, should compile the code while in its dir, so
     # relative require/open will work.
@@ -397,6 +397,7 @@
                     "sub handler {",
                     "local \$0 = '$script_name';",
                     $nph,
+                    $shebang,
                     $line,
                     ${ $self->{CODE} },
                     "\n}"; # last line comment without newline?
@@ -553,13 +554,13 @@
 }
 
 #########################################################################
-# func: rewrite_shebang
-# dflt: rewrite_shebang
+# func: shebang_to_perl
+# dflt: shebang_to_perl
 # desc: parse the shebang line and convert command line switches
 #       (defined in %switches) into a perl code.
 # args: $self - registry blessed object
-# rtrn: nothing
-# efct: the CODE field gets adjusted
+# rtrn: a Perl snippet to be put at the beginning of the CODE field
+#       by caller
 #########################################################################
 
 my %switches = (
@@ -572,7 +573,7 @@
    'w' => sub { "use warnings;\n" },
 );
 
-sub rewrite_shebang {
+sub shebang_to_perl {
     my $self = shift;
     my($line) = ${ $self->{CODE} } =~ /^(.*)$/m;
     my @cmdline = split /\s+/, $line;
@@ -588,7 +589,8 @@
             $prepend .= $switches{$_}->();
         }
     }
-    ${ $self->{CODE} } =~ s/^/$prepend/ if $prepend;
+
+       return $prepend;
 }
 
 #########################################################################


-- 
Dominique QUATRAVAUX                           Ingénieur senior
01 44 42 00 08                                 IDEALX

Attachment: pgpVJwYJcoJ9t.pgp
Description: PGP signature

Reply via email to