develooper Front page | perl.perl5.porters | Postings from December 2016

RE: File::Find on WSL

Thread Previous | Thread Next
From:
Thorsten Behrens
Date:
December 3, 2016 20:03
Subject:
RE: File::Find on WSL
Message ID:
SN1PR14MB0493D667D09277B9B3B4C89DCD810@SN1PR14MB0493.namprd14.prod.outlook.com
Alternative version, maybe a little more in line with what's already happening:

# These are hard-coded for now, but may move to hint files.
if ($^O eq 'VMS') {
    $Is_VMS = 1;
    $File::Find::dont_use_nlink  = 1;
}
elsif ($^O eq 'MSWin32') {
    $Is_Win32 = 1;
}
elsif ($^O eq 'linux') {
    open my $lv, '<', '/proc/version';
    if (index(<$lv>,'Windows') || index(<$lv>,'WSL')) {
        $File::Find::dont_use_nlink = 1;
    }
    close $lv;
}

From: Thorsten Behrens [mailto:tbehrens@outlook.com]
Sent: Saturday, December 3, 2016 2:54 PM
To: perl5-porters@perl.org
Subject: File::Find on WSL

Howdy,

As per discussion here https://github.com/Microsoft/BashOnWindows/issues/186, WSL confuses File::Find. WSL is the "Windows Subsystem for Linux", which runs Ubuntu on top of Windows 10.

File::Find sees that $^O is 'linux' and uses nlink, which doesn't work. After some discussion, this code added to Find.pm special-cases for WSL and solves the issue:

# Special-case for WSL by reading /proc/version
if ($^O eq 'linux') {
    open my $lv, '<', '/proc/version';
    if (index(<$lv>,'Windows') || index(<$lv>,'WSL')) {
        $File::Find::dont_use_nlink = 1;
    }
    close $lv;
}

This would likely go right after the "hard-coded for now" section that handles VMS and MSWin32.

@genio kindly pointed me to this mailing list for further discussion. If that code above is acceptable, I can follow instructions in http://perldoc.perl.org/perlhack.html and issue a pull request.

Yours
Thorsten


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