]> git.ipfire.org Git - thirdparty/coreutils.git/commit
Use more-consistent rules among cp, ln, and mv when dealing with
authorJim Meyering <jim@meyering.net>
Mon, 28 Jun 2004 18:39:28 +0000 (18:39 +0000)
committerJim Meyering <jim@meyering.net>
Mon, 28 Jun 2004 18:39:28 +0000 (18:39 +0000)
commit6860c032dac6a807a908125edd1dc2f95549ca5a
tree9951953e1d5b34f15b21ff517a1992785b76fe6e
parent59c3b539268fd48dd5fd9d63eacfd19534cc4146
Use more-consistent rules among cp, ln, and mv when dealing with
last operands that are (or look like) directories.

* src/cp.c (target_directory_operand): New, nearly-common function,
It reports an error if the destination appears to be a directory
(e.g., because it has a trailing slash) but is not.
* src/ln.c, src/mv.c: Likewise.
* src/cp.c (do_copy): Use it.
* src/ln.c (main): Likewise.
* src/mv.c (main): Likewise.

* src/cp.c (do_copy): Don't output a usage message because of file
problems (e.g., an operand is not a directory).  Use it only for
syntax.  Standardize on "target %s is not a directory" for the
diagnostic.
* src/ln.c (main): Likewise.
* src/mv.c (main): Likewise.

* src/cp.c (do_copy): Remove test for trailing slash, since
target_directory_operand now does this.
* src/ln.c (main): Likewise.
* src/mv.c (movefile): Likewise.

* src/ln.c (isdir): Remove decl; no longer needed.
* src/mv.c (isdir, lstat): Likewise.

* src/ln.c (main): Use int to count to argc, not unsigned int.
This handles negative operand counts.
* src/mv.c (main): Likewise.

* src/mv.c (do_move): Don't call hash_init; expect the caller to
do it, for consistency with cp.c and ln.c.  All callers changed.
(movefile): dest_is_dir parameter is now bool, not int.
(main): Standardize on "missing destination file operand after %s"
for the diagnostic, for consistency with cp.c.
src/mv.c