[prev in list] [next in list] [prev in thread] [next in thread] 

List:       perl5-porters
Subject:    Re: Case-insensitive file systems
From:       demerphq <demerphq () gmail ! com>
Date:       2023-04-16 21:29:01
Message-ID: CANgJU+Xa8wWBRKNGLMNSfuSOHWgbng7NN0xWzKL9p_py2mmcYg () mail ! gmail ! com
[Download RAW message or body]

On Sun, 16 Apr 2023 at 22:00, demerphq <demerphq@gmail.com> wrote:
> I also wonder if we couldn't tie %INC so that underneath it stored the
> filenames twice, once fold cased, such that we could detect whenever
> someone was loading a module name that differed from another already
> loaded only by case. Then we could warn when people did this type of
> mistake. In theory people could be doing this kind of thing
> deliberately on case-insensitive file systems, but i would hope that
> generally people would avoid that kind of pattern given how common
> case insensitive file systems are.

While poking into this I realized that on perl 5.38 and  5.37.x perls
with the require hooks in them, you should be able to do something
like:

my %INC_LC;
${^HOOK}{require__before} = sub {
   my ($file) = @_;
   if ($INC_LC{lc $file} and $INC_LC{lc $file} ne $file) {
     warn "Not loading $file which was already loaded as $file\n";
     $_[0] = ""; # halt the require.
   } else {
     $INC_LC{lc $file} = $file;
   }
   return;
};

Untested as I dont have a case-insensitive file system, but the basic
idea is there.

Yves

-- 
perl -Mre=debug -e "/just|another|perl|hacker/"
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic