develooper Front page | perl.perl5.porters | Postings from April 2003

Re: windows, shortcuts and 'use lib'

Thread Previous | Thread Next
From:
Nicholas Clark
Date:
April 27, 2003 12:04
Subject:
Re: windows, shortcuts and 'use lib'
Message ID:
20030427185727.GB270@Bagpuss.unfortu.net
On Sat, Apr 26, 2003 at 10:02:33PM -0400, Benjamin Goldberg wrote:
> Edward Peschko wrote:
> > 
> > hey,
> > 
> > I just noticed that on Windows - at least in the activestate build -
> > perl doesn't handle
> > 
> > use lib 'shortcut.lnk';
> > 
> > This is very unfortunate for us who want to take our unix environments
> > and make them work seamlessly on NT (and need the capability of
> > symbolic links and are willing to fake them via shortcuts).
> > 
> > Anyways, would people be interested in a patch to 'use lib'? I'd rather
> > not write another directive, because of the ubiquitousness of 'use lib'
> > and the fact that other modules out of my control use it extensively...
> 
> A better patch (imho) would be to make the "-l" operator return true for
> filenames which end in ".lnk", and hack "readlink" on windows to grock
> the format of shortcut files.  Then, one could write:
> 
>    use lib readlink('shortcut.lnk');
> 
> Which would thus require no alteration of lib.pm.
> 
> Or at least it would make the patch to lib.pm much smaller.
>
> Of course, if such hackery were added, users might become tempted to use
> shortcuts as if they really *were* full fledged symbolic links, and try
> and open paths like "C:/path/foo.lnk/bar" ... which wouldn't be work,
> unless we did lots more hackery... thus, this might not be a good idea.

Are there enough hooks in the core routines yet to make it possible to write
a module that tweaks all file operations to work with/round shortcuts?

If not, putting in enough hooks to make that work would seem a better still
patch. Alternative a patch to lib.pm that allows modules to hook into to it
to extend its capabilities would seem more general purpose - that way your
script could load one module at the start to allow use lib in all third party
modules to work seamlessly. Others might have other requirements.
(As usual, the only one I can think of is loading zip files, but it strikes
me that such a hook would be very useful to ex::lib::zip)

I would consider a patch that alters only -l much less clean than a patch that
specifically and clearly makes lib.pm grok windows links.

Nicholas Clark

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About