diff options
-rw-r--r-- | THANKS | 1 | ||||
-rw-r--r-- | src/copy.c | 6 | ||||
-rwxr-xr-x | tests/mv/trailing-slash | 8 |
3 files changed, 15 insertions, 0 deletions
@@ -362,6 +362,7 @@ M. P. Suzuki mpsuzuki@hiroshima-u.ac.jp Maciej Kwapulinski pikpok@univ.gda.pl Manas Garg manas@cygsoft.com Manfred Hollstein manfred@s-direktnet.de +Марк Коренберг socketpair@gmail.com Marc Boucher marc@mbsi.ca Marc Haber mh+debian-bugs@zugschlus.de Marc Lehman schmorp@schmorp.de 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; diff --git a/tests/mv/trailing-slash b/tests/mv/trailing-slash index b58c90822..906174afa 100755 --- a/tests/mv/trailing-slash +++ b/tests/mv/trailing-slash @@ -50,4 +50,12 @@ done #touch a a2 #mv a a2/ && fail=1 +# Test for a cp-specific diagnostic introduced after coreutils-8.7: +printf '%s\n' \ + "cp: cannot create regular file \`no-such/': Not a directory" \ +> expected-err +touch b +cp b no-such/ 2> err && fail=1 +compare err expected-err || fail=1 + Exit $fail |