> So, when you follow the name of a softlink with a /, mv derefrences the
> softlink and moves the result.
>
> I haven't thought this through, but it sure seems counterintuitive. It
> also kind of makes bash filecompletion bite, as this always sticks the
> slash on the end of a directory.
This might be counterintuitive only because you don't understand the
rule. The rule is that if you name it exactly (no slash on the end)
then you get whatever that file is. If you name it and also have a
slash on the end then you always push through symlink and act on the
file past the symlink. This is common for all utilities such as 'ls'
and others. This has been the traditional behavior of UNIX for years.
I think since BSD introduced symlinks in the first place. I think
this might be defined by POSIX.
Most of the behavior has been behind the system calls that implement
the behavior and not in any 'mv' or 'ls' command. Which is why this
behavior is common to almost all UNIX utilities. In order to avoid
this all of the utilities would have to do special checking. I don't
like that idea since you would never get them all to agree on the
right common set of checking. There would always be new code written
tomorrow that did not follow that rule. The best place to make the
change if you were going to do it would be in the kernel code that
implements the system calls themselves since that would at least give
a consistent interface across all commands.
In any case, I would not want to change this since it would be a break
from traditional behavior that stretches years and years. It is
really more of a problem with understanding the use model than a
problem with the code. I am talking generically because I know that
older versions of GNU 'mv' did not act that way and I always thought
it was a bug that it was different. The newer versions seems to have
fixed this and now acts "correctly" IMNHO. Consistent and standard
behavior is better than random better behavior that is all different
everywhere.
My two cents.
Bob Proulx
P.S. Symlinks are much too useful to do without. But they have always
caused interesting interactions which have been confusing over the
years.