List Info

Thread: Re: filetests sometimes do not set _




Re: filetests sometimes do not set _
user name
2007-10-17 03:49:05
On 17/10/2007, Mark Overmeer <markovermeer.net> wrote:
> Hum... the error report was even more right than I
expected it to be...
> After a long bug-hunt, I figured out that it is not
'-w' itself which
> is misbehaving (the file test flags), but it is the
module 'filetest'.
>
> The following script reports 'directory' twice:
>
>    #!/usr/local/bin/perl5.10.0
>    use filetest 'access';
>
>    -d '/etc';
>    -w '/etc/passwd';
>    warn -f _ ? "filen" :
"directoryn";
>    warn -d _ ? "directoryn" :
"filen";
>
> Apparently, -r/-w/-x/-R/-W/-X implemented in filetest
to not
> set '_' anymore, where they did so in perl5.8.8

Looking at the code, I think this bug was already present in
5.8.x.
But maybe the access code wasn't compiled in your version.

What does
perl -V:.*access.*
show for each of your perls ?

Re: filetests sometimes do not set _
user name
2007-10-17 04:02:18
* Rafael Garcia-Suarez (rgarciasuarezgmail.com) [071017 08:49]:
> On 17/10/2007, Mark Overmeer <markovermeer.net> wrote:
> > Apparently, -r/-w/-x/-R/-W/-X implemented in
filetest to not
> > set '_' anymore, where they did so in perl5.8.8
> 
> Looking at the code, I think this bug was already
present in 5.8.x.
> But maybe the access code wasn't compiled in your
version.
> 
> What does
> perl -V:.*access.*
> show for each of your perls ?

markovearth:&perl> perl5.10.0 -V:.*access.*
d_access='define';
d_accessx='undef';
d_eaccess='undef';
i_sysaccess='undef';

markovearth:&perl> perl5.8.7 -V:.*access.*
d_access='define';
d_accessx='undef';
d_eaccess='undef';
i_sysaccess='undef';

The code which now fails was ran by cpan-testers on many
many
systems, without problems in 5.6 and 5.8, but fails on all
5.10/5.9.5

According to the cpantesters results
(http:/
/cpantesters.perl.org/show/Mail-Box.html), it looks like
something
broke between 5.9.2 and 5.9.5.

By the way: quite some 5.9.5 tests reported successes, but
actually
were failures.
-- 
               MarkOv

------------------------------------------------------------
------------
       Mark Overmeer MSc                               
MARKOV Solutions
       MarkOvermeer.net                          solutionsovermeer.net
http://Mark.Overmeer.net
                  http://solutions.overme
er.net


Re: filetests sometimes do not set _
user name
2007-10-21 15:53:37
On Wed, Oct 17, 2007 at 10:22:58AM +0200, Mark Overmeer
wrote:

> Hum... the error report was even more right than I
expected it to be...
> After a long bug-hunt, I figured out that it is not
'-w' itself which
> is misbehaving (the file test flags), but it is the
module 'filetest'.
> 
> The following script reports 'directory' twice:
> 
>    #!/usr/local/bin/perl5.10.0
>    use filetest 'access';
> 
>    -d '/etc';
>    -w '/etc/passwd';
>    warn -f _ ? "filen" :
"directoryn";
>    warn -d _ ? "directoryn" :
"filen";
> 
> Apparently, -r/-w/-x/-R/-W/-X implemented in filetest
to not
> set '_' anymore, where they did so in perl5.8.8

On Fri, Oct 19, 2007 at 02:20:26AM +0200, Andreas J. Koenig
wrote:

>     Change 19392 by jhikosh on 2003/05/03
05:33:04
> 
>         Salvage 'use filetest "access"' from
compiletime to runtime.

It seems that Jarkko actually fixed a bug here - I'd infer
that access() wasn't
being called when it was expected that it would be.

I don't believe that the current behaviour is a behavioural
bug.
The documentation could be clearer, however.

It is documented that _ is set to the last stat.
It is documented that under filetest, -r/-w/-x/-R/-W/-X use
access() rather
than the mode bits from the file.

Hence one does not need to call stat(), so perl does not.
*That*
implementation efficiency is not documented.

So I think that the current behaviour is preferable. If we
changed it so that
-r/-w/-x/-R/-W/-X also call stat() as well as access(), then
we give everyone
inefficiency that they can't avoid. Whereas the current
behaviour is merely
caveat emptor on anyone wishing to take advantage of the _
filehandle.

I'm curious - on a modern Unix system with decent OS
caching, how much does
not calling stat again really save?

Nicholas Clark

[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )