Re: [PATCHv2/RFC] gitweb: Prepare for splitting gitweb

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 7 Jul 2010, Jakub Narebski wrote:
> On Wed, 7 Jul 2010, Ævar Arnfjörð Bjarmason napisał:
> > On Wed, Jul 7, 2010 at 09:57, Jakub Narebski <jnareb@xxxxxxxxx> wrote:
> > > [...]
> > >  use strict;
> > >  use warnings;
> > > +
> > > +use File::Spec;
> > > +# __DIR__ is taken from Dir::Self __DIR__ fragment
> > > +sub __DIR__ () {
> > > +       File::Spec->rel2abs(join '', (File::Spec->splitpath(__FILE__))[0, 1]);
> > > +}
> > > +use lib __DIR__ . '/lib';
> > > +
> > 
> > What was the result of the discussion about using __DIR__ again? You
> > only need to use that method when you call a perl program whith *then*
> > includes a module. If you just need to add the lib/ directory relative
> > to the script you're invoking you can use FindBin:
> > 
> >     use FindBin qw($Bin);
> >     use lib "$Bin/lib";
> 
> It's
> 
>       use lib "$Bin/../lib";
> 
> (I don't like this ../lib here, but that's my personal preference).

Actually for gitweb, where gitweb.cgi is put in "top" directory, and
lib/ directory is in the same directory that the script is, it would
be

        use FindBin qw($Bin);
        use lib "$Bin/lib";

The documentation says that $FindBin::Bin is

        $Bin    - path to bin directory from where script was invoked

so it is path to directory, not to script itself.

If it worked...

> But you might be right that I am overly cautious in avoiding FindBin.
> It is nowadays not recommended solution (on #perl, for example), but
> it is perhaps true that the conditions where it fails are not fulfilled
> for the case of gitweb.
> 
> Or perhaps not:
> 
>   KNOWN ISSUES
> 
>   If there are two modules using FindBin from different directories
>   under the same interpreter, this won't work. Since FindBin uses a
>   BEGIN block, it'll be executed only once, and only the first caller
>   will get it right. This is a problem under **mod_perl** and other
>   persistent Perl environments, where you shouldn't use this module.
> 
> Gitweb can be used under mod_perl (to be more exact ModPerl::Registry).

I wrote simple script that tests result of __DIR__ and $FindBin::Bin.
For cgi-bin / mod_cgi it was:

  __DIR__       = /var/www/cgi-bin/gitweb (symlink to /home/local/gitweb)
  $FindBin::Bin = /home/local/gitweb

For mod_perl (ModPerl::Registry handler) it was

  __DIR__       = /var/www/perl/gitweb (symlink to /home/local/gitweb)
  $FindBin::Bin = /

As you can see it's useless.  I have't checked the FastCGI case...

-- 
Jakub Narebski
Poland
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]