diff options
author | Jim Meyering <jim@meyering.net> | 2004-06-28 18:38:05 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2004-06-28 18:38:05 +0000 |
commit | 59c3b539268fd48dd5fd9d63eacfd19534cc4146 (patch) | |
tree | 8d2d183cf7b6bf199ec693f49c560be0664b8e26 /src/env.c | |
parent | 8340545c8b2034b19c4ac681725922cd9c14cfbd (diff) | |
download | coreutils-59c3b539268fd48dd5fd9d63eacfd19534cc4146.tar.xz |
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/cp.c (main): Reject multiple target directories.
Check whether a specified target is a directory when parsing the
options, using stat. This gives more-accurate diagnostics.
* src/ln.c (main): Likewise.
* src/ln.c (isdir): Remove decl; no longer needed.
* src/mv.c (isdir, lstat): Likewise.
* src/ln.c (do_link): New arg dest_is_dir. All uses changed.
Don't check the destination ourself; rely on dest_is_dir.
This way we can avoid lstatting the destination in the
usual case, and in the worst case we lstat 1, not 3 times.
Don't bother to unlink unless link failed; this saves a syscall.
Remove unnecessary backup_succeeded flag;
it was identical to "dest_backup != NULL".
* src/ln.c (main): Use int to count to argc, not unsigned int.
This handles negative operand counts.
* src/mv.c (main): Likewise.
Diffstat (limited to 'src/env.c')
0 files changed, 0 insertions, 0 deletions