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

Re: File::Find on WSL

Thread Previous | Thread Next
Sawyer X
December 6, 2016 20:20
Re: File::Find on WSL
Message ID:
Thorsten, thank you for raising this issue and working on solving it! :)

On 12/04/2016 01:29 PM, Leon Timmermans wrote:
> On Sun, Dec 4, 2016 at 5:12 AM, Uri Guttman <
> <>> wrote:
>     do you want that to be a warn or a die? i would call die as that
>     means the $^O is misleading or something made /proc/version
>     disappear. a warning does little good there as the typical caller
>     of file::find won't understand what is wrong.
> It is possible (but unusual) for /proc not to exist.

That's what I remembered too.

I see a very narrow problem scope here: If it's WSL and there is no
/proc/version or the /proc/version is wrong. If WSL guarantees to have
/proc/version existing and set to the right value, then there's no
reason to die or warn. It becomes this simple "best effort" statement:

if ( $^O eq 'linux' && open my $fh, '<', '/proc/version' ) {
    my $line = <$fh>;

    $line =~ /(Microsoft|WSL)/
        and $File::Find::dont_use_nlink = 1;

    close $fh
        or die "Cannot close /proc/version: $!\n";

(Pending any bike-shedding on the actual code - I have no opinion.)
(The $^O check can be a separate condition, so other non-WSL statement
could go there too in the future, for example.)

Do I understand this correctly?

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About