Bogdan TARU wrote: > As you can see, when I tried to remove the symlink 'b' with a trailing > slash 'rm -rf b/', the target directory was removed instead of the actual > symlink. Of course, this is weird (tryied it on some other 10 un*xes, and > all worked in another way). > > I have attached a patch for the 'rm' untility, which strips the trailing > slash(es) from the path (according to Posix.2). But I think there are many > other utilities which need to be patched (e.g. cp, mv).
The trailing "/" is supposed to be this way. It means "evaluate the preceeding as a directory". This is a kernel thing: it's what makes "ls -l symlink-to-dir" show the symlink, and "ls -l symlink-to-dir/" show the contents of the directory pointed to by the symlink). You will also notice that when you are tab-expanding a symlink to a directory in tcsh (now csh), that it automatically adds the trailing "/"... in fact, if I had to guess, this is where I would expect that you had seen the behaviour. For a recursive removal of a symlink or a directory containing a symlink, this makes sense, actually, since the idea of recursively removing something you can't recurse into *doesn't* make sense. If you were going to patch this at all, the only thing that *might* make sense is to do an lstat() before deciding to recurse into the thing. Notice that an lstat on "symlink-to-dir/" acts like stat; while without the trailing "/", it does not. This also reinforces the correctness of the behaviour. Are you maybe using an alias which expand to "rm -rf $*"?? -- Terry To Unsubscribe: send mail to [EMAIL PROTECTED] with "unsubscribe freebsd-hackers" in the body of the message