[buug] ln -sf bug

Stefan Lasiewski flarg at flarg.org
Fri Aug 6 15:12:23 PDT 2004


I think it will remove destination files, but not destination directories.

While this may violate the principal of least suprises, I think it's designed
that so you don't accidently blow away an active symlink. ... or something
...

% touch file1 file2
% ln -fs --verbose file1 link1
create symbolic link `link1' to `file1'
% ll
-rw-r--r--    1 Stefan L None            0 Aug  6 15:12 file1
-rw-r--r--    1 Stefan L None            0 Aug  6 15:12 file2
lrwxrwxrwx    1 Stefan L None            5 Aug  6 15:12 link1 -> file1

% ln -fs --verbose file2 link1
create symbolic link `link1' to `file2'

% ll
-rw-r--r--    1 Stefan L None            0 Aug  6 15:12 file1
-rw-r--r--    1 Stefan L None            0 Aug  6 15:12 file2
lrwxrwxrwx    1 Stefan L None            5 Aug  6 15:12 link1 -> file2

Now with directories, the behavior is different:

% mkdir dir1 dir2
% ln -fs --verbose dir1 link1
create symbolic link `link1' to `dir1'
% ll
drwxr-xr-x    2 Stefan L None            0 Aug  6 15:07 dir1
drwxr-xr-x    2 Stefan L None            0 Aug  6 15:07 dir2
lrwxrwxrwx    1 Stefan L None            4 Aug  6 15:07 link1 -> dir1

% ln -fs --verbose dir2 link1
create symbolic link `link1/dir2' to `dir2'
% ll
drwxr-xr-x    2 Stefan L None            0 Aug  6 15:07 dir1
drwxr-xr-x    2 Stefan L None            0 Aug  6 15:07 dir2
lrwxrwxrwx    1 Stefan L None            4 Aug  6 15:07 link1 -> dir1

% ll dir1
lrwxrwxrwx    1 Stefan L None            4 Aug  6 15:08 dir2 -> dir2


-= Stefan

--- johnd <john at jjdev.com> wrote:

> the man page says -fis supposed to remove existing destination files.
> 
> to me it seems that it doesn't
> 
> On Fri, Aug 06, 2004 at 02:10:51PM -0700, Chris Waters wrote:
> > On Fri, Aug 06, 2004 at 01:48:50PM -0700, Chris Waters wrote:
> > 
> > > Note the last result.  There's now a new link *inside* the directory
> > > pointed to by the old link!
> > 
> > Followup to my own post: I just tried the same thing on FreeBSD, and
> > got the same results, so apparently the behavior is considered correct
> > by more than one -dev team.
> > 
> > Now that I think about it, it is consistent with the behavior of cp
> > and mv.  So...maybe it doesn't violate the principle of least surprise
> > as much as I originally thought.
> > 
> > -- 
> > Chris Waters           |  Pneumonoultra-        osis is too long
> > xtifr at debian.org       |  microscopicsilico-    to fit into a single
> > or xtifr at speakeasy.net |  volcaniconi-          standalone haiku
> 
> -- 
> John de la Garza
> Computer Support
> (714) 315-5499
> http://jjdev.com/
> _______________________________________________
> Buug mailing list
> Buug at weak.org
> http://www.weak.org/mailman/listinfo/buug
> 


=====
----
'The art, or rather the knack
of flying is learning to throw
yourself to the ground and miss.'
-Douglas Adams, THGTTG



More information about the buug mailing list