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 22:02
Subject:
RE: File::Find on WSL
Message ID:
SN1PR14MB0493759F56A3483AD9CAC4FACD810@SN1PR14MB0493.namprd14.prod.outlook.com
Uri, thank you for your guidance and patience.

>>
you are using <$lv> twice but from what i see /proc/version only outputs one line. that means your second <$lv> if executed will return undef. you need to read $lv one time into a scalar and test against that value both ways. you also are not testing the open for failure even though you know (or think you know! :), it is a linux system from $^O. trust redmond to change something in /proc/version just to mess with people. :)
>>

How about this:

# 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 $pv, '<', '/proc/version' or warn "Can't open < /proc/version: $!";
    if ($pv) {
        my $lv = <$pv>;
        close $pv;
        if (index($lv,'Microsoft') != -1 || index($lv,'WSL') != -1) {
            $File::Find::dont_use_nlink = 1;
        }
    }
}

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