Re: Confirm a possible bug
On Thu, Jul 18, 2002 at 10:33:45AM -0400, Nikola Janceski wrote: I think I have stumbled onto a bug. I'd like one of the gurus (Jeff, druiex, Jenda or any perlguy.com) to confirm that my test is correct or if I missed something in docs. I'm not on that list, but I'll bite anyways :-) using Perl 5.6.1 on a Solaris sparc. #perl use strict; use warnings; my $wofile = noread;# text file with no read permissions my $file = canread; # text file with read perms if( -T $file ){ # will be true print exists\n if -e _; # will print } else { print doesn't exist\n unless -e _; } ## here's the possible bug if( -T $wofile ){ # will be false (you need read to determine if text file) ^^ correct... print exists\n if -e _; } else { print doesn't exist\n unless -e _; # will print BUT SHOULDN'T ^^ Why?!? The 'stat' structure is used. That structure has been filled by the -T, since the file has been accessed, regardless of the fact that the test for the 'text' type failed. The stat structure contains properties that rely on the working directories permissions and thus contains valid data. File permissions are irrelevant in that case. Or am I missing something? -- Well, then let's give that Java-Wussie a beating... (me) Michael Lamertz| +49 221 445420 / +49 171 6900 310 Nordstr. 49| [EMAIL PROTECTED] 50733 Cologne | http://www.lamertz.net Germany| http://www.perl-ronin.de -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Confirm a possible bug
On Jul 18, Nikola Janceski said: I think I have stumbled onto a bug. I'd like one of the gurus (Jeff, druiex, Jenda or any perlguy.com) to confirm that my test is correct or if I missed something in docs. I have confirmed the same result. The -T test on a file with no read permissions causes an EMPTY stat set to be returned. I'm currently patching Perl... -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for Regular Expressions in Perl published by Manning, in 2002 ** stu what does y/// stand for? tenderpuss why, yansliterate of course. [ I'm looking for programming work. If you like my work, let me know. ] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Confirm a possible bug
On Thu, Jul 18, 2002 at 04:53:46PM +0200, Michael Lamertz wrote: The 'stat' structure is used. That structure has been filled by the -T, since the file has been accessed, regardless of the fact that the test for the 'text' type failed. DUH! Me Idiot, Ugh! I mixed up || and in my own test and had thus printed the correct answer, but my test was bogus. Yepp, looks like the stat is empty... -- Well, then let's give that Java-Wussie a beating... (me) Michael Lamertz| +49 221 445420 / +49 171 6900 310 Nordstr. 49| [EMAIL PROTECTED] 50733 Cologne | http://www.lamertz.net Germany| http://www.perl-ronin.de -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Confirm a possible bug
It appears that -T cause perl to avoid doing the stat, opting for open and fstat instead (so that it can check the file header to see if it's text). The open of course fails, and thus the stat does not get populated. On Thursday, July 18, 2002, at 11:04 AM, Michael Lamertz wrote: On Thu, Jul 18, 2002 at 04:53:46PM +0200, Michael Lamertz wrote: The 'stat' structure is used. That structure has been filled by the -T, since the file has been accessed, regardless of the fact that the test for the 'text' type failed. DUH! Me Idiot, Ugh! I mixed up || and in my own test and had thus printed the correct answer, but my test was bogus. Yepp, looks like the stat is empty... -- Well, then let's give that Java-Wussie a beating... (me) Michael Lamertz| +49 221 445420 / +49 171 6900 310 Nordstr. 49| [EMAIL PROTECTED] 50733 Cologne | http://www.lamertz.net Germany| http://www.perl-ronin.de -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] // George Schlossnagle // Principal Consultant // OmniTI, Inc http://www.omniti.com // (c) 240.460.5234 (e) [EMAIL PROTECTED] // 1024D/1100A5A0 1370 F70A 9365 96C9 2F5E 56C2 B2B9 262F 1100 A5A0 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Confirm a possible bug
On Jul 18, George Schlossnagle said: It appears that -T cause perl to avoid doing the stat, opting for open and fstat instead (so that it can check the file header to see if it's text). The open of course fails, and thus the stat does not get populated. That's exactly what I found. My patch (which has been sent to p5p): --- pp_sys.c.oldThu Jul 18 10:55:42 2002 +++ pp_sys.cThu Jul 18 11:23:42 2002 @@ -3340,6 +3340,9 @@ if (!(fp = PerlIO_open(SvPVX(PL_statname), r))) { if (ckWARN(WARN_NEWLINE) strchr(SvPV(sv, n_a), '\n')) Perl_warner(aTHX_ packWARN(WARN_NEWLINE), PL_warn_nl, open); + PUSHs(sv); + my_stat(); + (void) POPs; RETPUSHUNDEF; } PL_laststatval = PerlLIO_fstat(PerlIO_fileno(fp), PL_statcache); I also included an addition to the test suite. But now we're approaching OT. -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for Regular Expressions in Perl published by Manning, in 2002 ** stu what does y/// stand for? tenderpuss why, yansliterate of course. [ I'm looking for programming work. If you like my work, let me know. ] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]