bug-coreutils
[Top][All Lists]
Advanced

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

Re: mv trailing slash warning


From: Paul Eggert
Subject: Re: mv trailing slash warning
Date: Wed, 28 Sep 2005 11:26:23 -0700
User-agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux)

Jim Meyering <address@hidden> writes:

> As you can imagine, I find the POSIX-required behavior to be senseless.

Two things.

First, I recall that you preferred the non-POSIX behavior because of
file name completion issues.  But because we agitated about this a
while ago, Bash now does a better job with file name completion.  For
example, given this:

     mkdir dir
     ln -s dir symlink

If I type "mv sym[TAB]", where [TAB] stands for a tab character, the
screen then looks like this:

    mv symlink

If I type another [TAB] it then looks like this:

    mv symlink/

so I'm given a signal from Bash that I have a symlink to a directory,
and that it matters whether there's a trailing slash.

In the old days this didn't happen, the intermediate step was missing,
and so there was more of an argument that "mv symlink/ target" should
ignore the slash.  Nowadays, though, isn't that argument weaker?


Second, I just read the POSIX spec and it seems to be a bit buggy
<http://www.opengroup.org/onlinepubs/009695399/functions/rename.html>.
The rationale says "Renaming dot or dot-dot is prohibited" but I can't
see anything to that effect in the text itself.

Furthermore, POSIX says that a pathname like "abc/" must be resolved
as if it were "abc/." (see
<http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap04.html#tag_04_11>)
so arguably rename("abc/", "def") must be handled like rename("abc/.",
"def") and if renaming dot or dot-dot is prohibited (which I think it
must be, even if it's omitted inadvertently from the standard) then
this must fail.

There's a similar issue with "rmdir symlink/".  It's not clear that
rmdir ("symlink/") should succeed, because pathname resolution
indicates that it should be treated like rmdir ("symlink/.") and this
clearly must fail.


Clearly it's a messy area.

My kneejerk reaction is that I might prefer it if "mv symlink/ foo"
and "rmdir symlink/" always failed, if only because in a confusing
situation like this it's often better to use the Hippocratic rule:
first, do no harm.  It would be easy to implement that rule: it
wouldn't require any system calls at all, since we could simply reject
all file names with trailing slashes.




reply via email to

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