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

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

Mark Overmeer
November 30, 2007 08:05
Re: [perl #46463] filetests sometimes do not set _
Message ID:
> On Nov 30, 2007 8:11 AM, Mark Overmeer <> wrote:
> > * Jarkko Hietaniemi ( [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 ( [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.


       Mark Overmeer MSc                                MARKOV Solutions                          Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About