[Top][All Lists]

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

Re: rm symlink removes the target

From: Bob Proulx
Subject: Re: rm symlink removes the target
Date: Sat, 5 Oct 2002 10:50:14 -0600
User-agent: Mutt/1.4i

Leonardo Milano <address@hidden> [2002-10-04 10:27:26 -0400]:
> > If I do "rm -i symbolic_link_name", it goes to the
> > directory to which the symlink points to and asks
> > me to delete each file.
> The problem occurs _only_ if I end the symbolic name with
> a trailing backslash "/". In this case, rm tries to
> remove the directory to which "symbolic_link_name" points.
> If I DO NOT add the trayling backslash, it removes the
> link. If this is the expected behavior, I find it a little
> dangerous, since a shell script trying to delete 
> a symbolic linke may end up deleting a whole partition

Your problem is very similar to another problem.  Therefore I will
reproduce the previous message.


Michael McGuffin <address@hidden> wrote:
> I may have found a bug with mv.  When x is a symlink to
> a directory, the behaviour of
>    mv x y
> and
>    mv x/ y
> is not the same.  Please read the below description
> I wrote, and the response I got from Derrick Moser.

From: Jim Meyering <address@hidden>:

Thanks for the report, but that is the documented (and required, as I
understand the POSIX standard) behavior.  From the documentation
(e.g., run `info mv'):

     _Warning_: If you try to move a symlink that points to a directory,
  and you specify the symlink with a trailing slash, then `mv' doesn't
  move the symlink but instead moves the directory referenced by the
  symlink.  *Note Trailing slashes::.

And here's the above-referenced section on Trailing slashes:

  Trailing slashes

     Some GNU programs (at least `cp' and `mv') allow you to remove any
  trailing slashes from each SOURCE argument before operating on it.  The
  `--strip-trailing-slashes' option enables this behavior.

     This is useful when a SOURCE argument may have a trailing slash and
  specify a symbolic link to a directory.  This scenario is in fact rather
  common because some shells can automatically append a trailing slash
  when performing file name completion on such symbolic links.  Without
  this option, `mv', for example, (via the system's rename function) must
  interpret a trailing slash as a request to dereference the symbolic link
  and so must rename the indirectly referenced _directory_ and not the
  symbolic link.  Although it may seem surprising that such behavior be
  the default, it is required by POSIX and is consistent with other parts
  of that standard.

reply via email to

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