>From 430b30104234db719bf15e6fc681a62312c7124f Mon Sep 17 00:00:00 2001 From: Assaf Gordon Date: Mon, 29 Jul 2019 00:23:20 -0600 Subject: [PATCH] mv: improve ENOTEMPTY/EEXIST error message Suggested by Alex Mantel in https://bugs.gnu.org/36831 . $ mkdir A B B/A $ touch A/bar B/A/foo Before: $ mv A B mv: cannot move 'A' to 'B/A': Directory not empty After: $ mv A B mv: cannot move 'A' to 'B/A': Target directory not empty * src/copy.c (copy_internal): Add special handling for ENOTEMPTY/EEXIST. TODO: NEWS, tests. --- src/copy.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/copy.c b/src/copy.c index 65cf65895..a5af570bf 100644 --- a/src/copy.c +++ b/src/copy.c @@ -2450,6 +2450,14 @@ copy_internal (char const *src_name, char const *dst_name, return true; } + if (rename_errno == ENOTEMPTY || rename_errno == EEXIST) + { + error (0, 0, _("cannot move %s to %s: Target directory not empty"), + quoteaf_n (0, src_name), quoteaf_n (1, dst_name)); + forget_created (src_sb.st_ino, src_sb.st_dev); + return false; + } + /* WARNING: there probably exist systems for which an inter-device rename fails with a value of errno not handled here. If/as those are reported, add them to the condition below. -- 2.11.0