[comp.lang.perl] Bug in File test operator?

dgg@ksr.com (David Grubbs) (12/05/90)

To test if a pathname is really a directory, I got used to:

	if (! -l "pathname" && -d _) { code; }

where I originally (when I first started using PERL) thought I wanted:

	if (-d "pathname") { code; }

[The file test operators use "stat()", except for '-l' which uses "lstat()".]

It no longer works as I expect.  The following short test demonstrates it.

	if (-l "." || ! -d _) {		# "." is always a real directory.
	    print "Broken.\n";
	} else {
	    print "OK.\n";
	}

Stuff the above into a file (/tmp/perl_test) and feed it to 

	perl3.patch18 < /tmp/perl_test

		Output: OK.

	perl3.patch41 < /tmp/perl_test

		Output: Broken.

Has anyone else seen this?
--
David G. Grubbs				Kendall Square Research Corp.
{harvard,uunet,world}!ksr!dgg		dgg@ksr.com

ripley@opal.cs.tu-berlin.de (Hans-Ch. Eckert) (12/20/90)

In article <DGG.90Dec5151334@kaos.ksr.com> dgg@ksr.com (David Grubbs) writes:


	   if (-l "." || ! -d _) {		# "." is always a real directory.
	       print "Broken.\n";
	   } else {
	       print "OK.\n";
	   }

I can confirm that above lines print "Broken" on PL41 whereas I get
"OK" on PL37. We are running SunOS 4.1 here. I tried it on sun3 as
well as on sun4.

Greetings,
				RIPLEY
--
Greetings from RIPLEY | D-1000 Berlin 30    | ripley@opal.cs.tu-berlin.de
Hans-Christian Eckert | Regensburger Str. 2 | (ripley@tubopal.UUCP)