[comp.lang.perl] Rudeness on -l _

rbj@uunet.UU.NET (Root Boy Jim) (03/07/91)

I was just treated to what I consider a bogus error message:

	"You must supply explicit filename with -l"

The Book says (pg 85) "Likewise, -l _ will always be false
after a normal stat". Actually, tis fatal.

I am writing a recursive compare and remove script.
I only want to stat each file once. I need to know
what it is, so I was lstat'ing it, saving the results,
and later doing -f _, -d _, -l _.

It now looks like I'll have to -l it first, then do
-f _, -d _, etc later. I will also have to lstat(_),
as I need other info for optimizing equality tests.
-- 
		[rbj@uunet 1] stty sane
		unknown mode: sane

lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) (03/08/91)

In article <124842@uunet.UU.NET> rbj@uunet.UU.NET (Root Boy Jim) writes:
: I was just treated to what I consider a bogus error message:
: 
: 	"You must supply explicit filename with -l"
: 
: The Book says (pg 85) "Likewise, -l _ will always be false
: after a normal stat". Actually, tis fatal.
: 
: I am writing a recursive compare and remove script.
: I only want to stat each file once. I need to know
: what it is, so I was lstat'ing it, saving the results,
: and later doing -f _, -d _, -l _.
: 
: It now looks like I'll have to -l it first, then do
: -f _, -d _, etc later. I will also have to lstat(_),
: as I need other info for optimizing equality tests.

Oddly enough, I just worked on this yesterday after I ran into the same
problem.  The new behavior is to allow -l _ but not -l FILEHANDLE.
And -l _ will work correctly after lstat, but will now give a fatal error
after a stat, so that we prevent people from making that particular
stupid logical error before they've torn all their hair out.

I also made readlink non-fatal on systems that don't support it--it now
just returns undef, which is exactly what it would return on a non-link
file anyway, so why blow it out of the water?

Larry

rbj@uunet.UU.NET (Root Boy Jim) (03/08/91)

lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) writes:
?
?Oddly enough, I just worked on this yesterday after I ran into the same
?problem.  The new behavior is to allow -l _ but not -l FILEHANDLE.
?And -l _ will work correctly after lstat, but will now give a fatal error
?after a stat, so that we prevent people from making that particular
?stupid logical error before they've torn all their hair out.

Well, perhaps you could remember the filenames with the filehandles,
and either one with the statcache, so that -l would work on anything.
Nah! I'm lazy too. But it is possible.

I would rather see -l _ return undef after a stat. My concept of
undef translates roughly to "domain error". Fatal is excessive.

On the other hand, mistaking a symlink for a directory
is no fun either. Perhaps a quick death is better than a slow one.

?Larry
-- 
		[rbj@uunet 1] stty sane
		unknown mode: sane