develooper Front page | perl.perl5.porters | Postings from November 2007

Re: [perl #46463] filetests sometimes do not set _

From:
Mark Overmeer
Date:
November 30, 2007 08:05
Subject:
Re: [perl #46463] filetests sometimes do not set _
Message ID:
20071130160531.GM12588@earth.overmeer.net
> On Nov 30, 2007 8:11 AM, Mark Overmeer <mark@overmeer.net> wrote:
> > * Jarkko Hietaniemi (jhi@iki.fi) [071130 12:55]:
> > > In principle I approve clarifications but it seems to me that you are
> > > losing some information in this edit, and I do not think EXCLAMATION
> > > POINTS to perlfunc!!! :-)

* Jarkko Hietaniemi (jhi@iki.fi) [071130 14:06]:
> What exactly are you trying to add / change?  Something about the
> semantics of the -X vs _, but what?

The changed text should reflect the debates on the porters lists, which
we had a month or so ago.  5.10.0 had a changed behavior with my tests,
and this has something to do with filetest.  Probably, some bug was
removed which has hidden a problem with filetest for me.

in short

  -r $filename
       should be used sparsely: chance on race conditions in case
       of combinations with other functions on that file.

  no filetest 'access'   # default
  -r $filename
       tests the read-bit in mode field of stat(), it does not
       promise readability (on most platforms)

  use filetest 'access'
  -r $fn
       does check for readability correctly, but doesn't use _

Under the filetest pragma, -r/-w/-x do not set '_'.  There was no
indication of this "feature" in the manuals.  And, yes, this behavior
is very dangerous, because the pragma is typically added later, when
porting to a platform which requires it.

IMO, filetest 'access' should be default, and we should try to trick
'_' by adding an extra stat.  But that's 5.10.1 or 5.12 material.

The patches I provide include two major changes.
 - The filetest pragma is described in a bit more detail, and reorganized.
   Nothing thrown away, afaik.
 - the perlfunc/-X has a warning and reference to the filetest pragma.  A
   paragraph which contained a condensed version of the filetest text
   was removed, because it is too short to explain such complex concept.

Changes to the text are (of course) possible.  At least, this suggestion
attempts to describe the situation better then the current text.
-- 
Regards,

               MarkOv

------------------------------------------------------------------------
       Mark Overmeer MSc                                MARKOV Solutions
       Mark@Overmeer.net                          solutions@overmeer.net
http://Mark.Overmeer.net                   http://solutions.overmeer.net




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