bug-fileutils
[Top][All Lists]
Advanced

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

"mv --reply=no" surprising results


From: Clifford T. Matthews
Subject: "mv --reply=no" surprising results
Date: Fri, 10 Jan 2003 15:52:25 -0700

Howdy,

It appears to me that either there's a bug in the implementation of
the "--reply=no" option for mv, or the man page is exceedingly
misleading and the info page is fairly misleading.  Apparently the
semantics of --reply=no are to silently overwrite an existing file if
permissions allow it:

address@hidden tmp]$ echo foo > delme
address@hidden tmp]$ echo bar > delme2
address@hidden tmp]$ mv --reply=no delme delme2
address@hidden tmp]$ ls -l delme*
-rw-r--r--    1 ctm      ardi            4 Jan 10 15:18 delme2
address@hidden tmp]$ cat delme2
foo
address@hidden tmp]$ mv --version
mv (fileutils) 4.1.9
Written by Mike Parker, David MacKenzie, and Jim Meyering.

Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

The man page says:

       --reply={yes,no,query}
              specify how to handle the prompt about an  existing  destination
              file

which a reader, especially one familiar with "-i", might assume means
that using --reply=no would be the same thing as

     echo no | mv -i delme delme2 2> /dev/null

The info page says:

`--reply[=HOW]'
     Specifying `--reply=yes' is equivalent to using `--force'.
     Specify `--reply=no' to make `mv' act as if `no' were given as a
     response to every prompt about a destination file.  Specify
     `--reply=query' to make `mv' prompt the user about each existing
     destination file.

So the man page talks about a prompt about an existing destination
file, when no such prompt, per-se, will be generated, since you need
-i to generate such a prompt.  When -i and --reply=no are on the same
line, you get the behavior of whichever option appears last (right
most).

The info page doesn't suggest that a prompt would ever be issued when
there's an existing destination file, it just mentions prompts about
destination files, which includes the case of the destination file not
having write permission but doesn't explicitly mention that the prompt
you would get if you added "-i" does not count.

It would be nice if the documentation could more explicitly address
what should happen when --reply=no is used with mv, whether the
semantics are supposed to be to overwrite an existing file or not.
Part of the problem with the current documentation is it talks about
prompts rather than about conditions.  Even when --reply=no results in
a file not being renamed due to the destination file (e.g. due to not
having write permission), no prompt is written.

The documentation should probably explicitly state whether --reply
affects the printing of the prompt, under which conditions the file
will or won't be overwritten, what the exit status of mv will be and
how --reply interacts with other command line options.  Beyond that,
if the semantics are really that a pre-existing destination file
should be overwritten with --reply=no, it might make sense to include
a warning and an example (e.g. echo n | ... ) of how to rename but not
overwrite.

--Cliff Matthews        After their escape, purchases of
address@hidden          lightweight fabrics were limited




reply via email to

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