summaryrefslogtreecommitdiff
path: root/src/copy.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2010-11-21 18:50:41 -0800
committerPaul Eggert <eggert@cs.ucla.edu>2010-11-22 00:04:50 -0800
commit013d95af11f41cbe05abdb73c997040dce4301f8 (patch)
tree41f34f8864051e6cf0d219c3a29d2c9060d870f0 /src/copy.c
parentbe107398e56e9f6ada8cd558b3f43bb1ed70fb84 (diff)
downloadcoreutils-013d95af11f41cbe05abdb73c997040dce4301f8.tar.xz
cp: give a better diagnostic for nonexistent dest/
This patch was written by Jim Meyering and myself. * src/copy.c (copy_reg): Turn EISDIR to ENOTDIR to improve the quality of diagnostics for commands like "cp a nosuch/". Reported by Марк Коренберг and Alan Curry in the thread starting at: http://lists.gnu.org/archive/html/bug-coreutils/2010-11/msg00178.html * THANKS: Update. * tests/mv/trailing-slash: Add a test.
Diffstat (limited to 'src/copy.c')
-rw-r--r--src/copy.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/copy.c b/src/copy.c
index 07501dfd4..42d6d9249 100644
--- a/src/copy.c
+++ b/src/copy.c
@@ -603,6 +603,12 @@ copy_reg (char const *src_name, char const *dst_name,
}
}
}
+
+ /* Improve quality of diagnostic when a nonexistent dst_name
+ ends in a slash and open fails with errno == EISDIR. */
+ if (dest_desc < 0 && dest_errno == EISDIR
+ && *dst_name && dst_name[strlen (dst_name) - 1] == '/')
+ dest_errno = ENOTDIR;
}
else
omitted_permissions = 0;