Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx> writes: >> Documentation says "If you are absolutely certain that you want your >> script to load and execute a file from the current directory, then use >> a ./ prefix". We can do that, like so: >> >> diff --git i/gitweb/Makefile w/gitweb/Makefile >> index cd194d057f..3160b6cc5d 100644 >> --- i/gitweb/Makefile >> +++ w/gitweb/Makefile >> @@ -18,7 +18,7 @@ RM ?= rm -f >> INSTALL ?= install >> >> # default configuration for gitweb >> -GITWEB_CONFIG = gitweb_config.perl >> +GITWEB_CONFIG = ./gitweb_config.perl >> GITWEB_CONFIG_SYSTEM = /etc/gitweb.conf >> GITWEB_CONFIG_COMMON = /etc/gitweb-common.conf >> GITWEB_HOME_LINK_STR = projects >> >> but that does not help if someone overrides GITWEB_CONFIG, and besides, >> it would be nicer to avoid the possibility of an @INC search altogether. >> ... > Just: > > local @INC = '.'; > do 'FILE.pl'; > > Would do the same thing, but seems like a more indirect way to do it if > all we want is ./ anyway. Yeah, it does look indirect. Despite what you said, it also would support users giving an absolute path via GITWEB_CONFIG. With "use File::Spec", perhaps something like this? gitweb/gitweb.perl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index 2594a4badb..239e7cbc25 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -719,6 +719,10 @@ sub filter_and_validate_refs { sub read_config_file { my $filename = shift; return unless defined $filename; + + $filename = File::Spec->catfile(".", $filename) + unless File::Spec->file_name_is_absolute($filename); + # die if there are errors parsing config file if (-e $filename) { do $filename;