bug-coreutils
[Top][All Lists]
Advanced

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

Re: ln -sf foo symlink_to_directory


From: Paul Jarc
Subject: Re: ln -sf foo symlink_to_directory
Date: Fri, 06 Feb 2004 12:21:13 -0500
User-agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.3 (gnu/linux)

Jim Meyering <address@hidden> wrote:
> The behavior of `ln -s' in that case is compatible with
> historical BSD implementations.  You'd like the SYSV behavior.

I think a new option would be useful - I'll call it --syntactic, but
that may not be a good name.  --syntactic means that the filenames
passed to link() or symlink() (or rename() or open(), as this would
also be useful for mv & cp) are computed entirely from the
command-line parameters, without checking to see what happens to exist
in the filesystem.  The target name is treated as a directory (and
thus gets the source basename appended) only if it syntactically ends
with "/".  So:
ln --syntactic foo bar     # link("foo", "bar"), regardless of what exists now
ln --syntactic -s foo bar/ # symlink("foo", "bar/foo")
mv --syntactic foo bar     # rename() will fail if bar is a directory; good!
cp --syntactic foo bar baz # error; baz is not a directory, syntactically

This way, you can easily see that the command will (try to) do what
you intend it to do, without worrying about what might exist already.
If the pre-existing contents of the filesystem make it impossible to
do what you intended to do, you'll get an error instead of some
alternate, unintended behavior.


paul




reply via email to

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