Front page | perl.perl5.porters |
Postings from December 2016
Re: File::Find on WSL
Thread Previous
|
Thread Next
From:
Uri Guttman
Date:
December 3, 2016 21:32
Subject:
Re: File::Find on WSL
Message ID:
584339F1.8030506@stemsystems.com
On 12/03/2016 03:25 PM, Thorsten Behrens wrote:
>
> I need to apologize. My heart’s in the right place, my coding skills
> are not, and I’m spamming you. The code I sent so far is nonsense.
> That’s not how index() works. This, after some testing, works. Attempt #3:
>
> As per discussion here
> https://github.com/Microsoft/BashOnWindows/issues/186
> <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:
>
> # 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>,'Microsoft') != -1 || index(<$lv>,'WSL') != -1) {
>
> $File::Find::dont_use_nlink = 1;
>
>
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. :)
uri
Thread Previous
|
Thread Next