ln -f

John F. Haugh II jfh at rpp386.cactus.org
Sun Jul 29 06:32:40 AEST 1990


In article <3770 at auspex.auspex.com> guy at auspex.auspex.com (Guy Harris) writes:
>>But that doesn't give the same result.  If you remove file2 first, then
>>there is a brief window between the 'rm' and the 'ln' during which no
>>file named file2 exists.  
>>If you use a version of 'ln' that clobbers file2 and replaces it with a
>>link to file1 in an atomic operation, there is no such window.
>
>As far as I know, there's no such atomic operation, either; I sure
>haven't seen any such operation in any UNIX system I've ever run into.
>
>Given that, every version of "ln" I know of that removes the target
>first has to first "unlink()" the target, and then do the "link()".  As
>such, the window is still there....

My complaint is because 1). the behavior is useful [ obviously, since
AT&T and BSD both have ln's with different behaviors and no one has yet
decided that either is patently stupid ] 2). the behaviors are
different so you can't know whether the ln on the system you are using
is going to fail or succeed, depending on your definition of failure
or success.  Which means you are forced to use "rm -f $2 ; ln $1 $2"
to have the desired effect [ again, or not, depending on what "the
desired effect" is ].

Standardizing on "ln" and "ln -f" behavior, as I believe POSIX is trying
to do, will resolve the problem - there will be exactly one set of
POSIX-like "ln" and "ln -f" behavior.
-- 
John F. Haugh II                             UUCP: ...!cs.utexas.edu!rpp386!jfh
Ma Bell: (512) 832-8832                           Domain: jfh at rpp386.cactus.org



More information about the Comp.unix.wizards mailing list