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.
This commit is contained in:
Paul Eggert committed 2010-11-22 00:04:50 -08:00
1 parent be107398e5
commit 013d95af11
3 files changed
+15

No files matched your search

+6
View File
@@ -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;