how to compare file modification time in bourne shell script

Chris Torek chris at mimsy.umd.edu
Thu Aug 2 20:08:53 AEST 1990


In article <324 at sun13.scri.fsu.edu> mayne at VSSERV.SCRI.FSU.EDU
(William (Bill) Mayne) writes:
>Others have suggested the use of make to [compare file modtimes]....
>Just in case my main question gets hidden in the fog, I will restate
>it: The timestamp of a symbolic link is the time when the link was
>created, rather than the last modication of the file ultimately
>referenced.

Right.

>Thus a make file which refers to a symbolic link is fooled.

Wrong---or `should be wrong', at least.

>Why was the system designed in a way that makes this use of make so 
>difficult?

It was not.

Although symbolic links do occupy an inode, and therefore have all the
information a `stat' operation can find, they are not normally supposed
to be examined by programs.  Indeed, it requires a special system call
(lstat()) to get this information: most system calls follow symlinks to
their ultimate destinations.  (The only other lookup operations that do
not follow symlinks are chown(), probably because the space used for the
target of the link is charged to the owner and thus this must be
changeable, and readlink(), for the obvious reason.  Removal operations,
of course, do not follow symlinks.  Normal creation operations do; opens
for creating with O_EXCL do not.)

Only a few programs---e.g., find (which must not follow symlinks since
they may not form a tree) and ls (which should show the name and target,
or whatnot)---have any business using lstat().  `Make' is not such a
program.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris at cs.umd.edu	Path:	uunet!mimsy!chris



More information about the Comp.unix.questions mailing list