From 013d95af11f41cbe05abdb73c997040dce4301f8 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 21 Nov 2010 18:50:41 -0800 Subject: cp: give a better diagnostic for nonexistent dest/ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- src/copy.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/copy.c') 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; -- cgit v1.2.3