bug-fileutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

"ln -f" does not work for directory links


From: Marc-Jano Knopp
Subject: "ln -f" does not work for directory links
Date: Thu, 28 Nov 2002 13:34:46 +0100
User-agent: Mutt/1.5.1i

Hi!

I've always wondered why sometimes "ln -[s]f" would work and sometimes
it would not. Now I found out: "ln -f" only works for symbolic or hard
links to files, but not for symbolic links to directories.

Example:

  $ mkdir /tmp/links
  $ cd /tmp/links
  $ touch file-1 file-2
  $ mkdir dir-1 dir-2
  $ ll
  total 16
  drwxr-xr-x    2 mjk      users        4096 Nov 28 13:24 dir-1
  drwxr-xr-x    2 mjk      users        4096 Nov 28 13:24 dir-2
  -rw-r--r--    1 mjk      users           0 Nov 28 13:24 file-1
  -rw-r--r--    1 mjk      users           0 Nov 28 13:24 file-2
  $
  $ # Let's see if it works for files:
  $
  $ ln -s file-1 file
  $
  $ ls -l file*
  total 16
  lrwxrwxrwx    1 mjk      users           6 Nov 28 13:25 file -> file-1
  -rw-r--r--    1 mjk      users           0 Nov 28 13:24 file-1
  -rw-r--r--    1 mjk      users           0 Nov 28 13:24 file-2
  $
  $ ln -sf file-2 file
  $
  $ ls -l file*
  lrwxrwxrwx    1 mjk      users           6 Nov 28 13:27 file -> file-2
  -rw-r--r--    1 mjk      users           0 Nov 28 13:24 file-1
  -rw-r--r--    1 mjk      users           0 Nov 28 13:24 file-2
  $
  $ # Hooray, it worked!
  $ # Now let's see if it works for directories as well:
  $
  $ ln -s dir-1 dir
  $
  $ ls -ld dir*
  lrwxrwxrwx    1 mjk      users           5 Nov 28 13:28 dir -> dir-1
  drwxr-xr-x    2 mjk      users        4096 Nov 28 13:24 dir-1
  drwxr-xr-x    2 mjk      users        4096 Nov 28 13:24 dir-2
  $
  $ ln -sf dir-2 dir
  $
  $ ls -ld dir*
  lrwxrwxrwx    1 mjk      users           5 Nov 28 13:28 dir -> dir-1
  drwxr-xr-x    2 mjk      users        4096 Nov 28 13:28 dir-1
  drwxr-xr-x    2 mjk      users        4096 Nov 28 13:24 dir-2
  $
  $ # No, doesn't work :-(
  $

Please fix :-)

And a question: After all these years, am I the first to report this
bug? Did no-one ever notice?


Best regards

  Marc-Jano





reply via email to

[Prev in Thread] Current Thread [Next in Thread]