aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDenys Nykula <nykula@ukr.net>2019-06-22 14:57:59 +0300
committerRob Landley <rob@landley.net>2019-06-22 09:05:53 -0500
commit3b9cfa70db019fa9b43ddba2d5620bff6c72bad6 (patch)
tree17ba946b54145c3949a8ac3b3d9c229bab15a26d /tests
parent10534db2f6145dac85689e773d53befa4ce91c7d (diff)
downloadtoybox-3b9cfa70db019fa9b43ddba2d5620bff6c72bad6.tar.gz
Fix mv with trailing slash in source.
Press tab, have bash complete dir name with a slash, notice musl rename() dislikes that. Replace trailing slash in the cp loop with a null character, if the command name is mv. Add the slash back if an error occurs.
Diffstat (limited to 'tests')
-rwxr-xr-xtests/mv.test20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/mv.test b/tests/mv.test
index f1f4a4f9..ed8922ac 100755
--- a/tests/mv.test
+++ b/tests/mv.test
@@ -96,6 +96,26 @@ testing "dir to existing dir" \
"yes\n" "" ""
rm -rf dir*
+# Trailing slash was once throwing: bad 'dir1/dir2/': Resource busy
+mkdir -p dir1/dir2
+testing "dir1/dir2 to ." \
+ "mv dir1/dir2 . && [ ! -e dir1/dir2 -a -d dir2 ] && echo yes" \
+ "yes\n" "" ""
+rm -rf dir*
+mkdir -p dir1/dir2
+testing "dir1/dir2/ to ." \
+ "mv dir1/dir2/ . && [ ! -e dir1/dir2 -a -d dir2 ] && echo yes" \
+ "yes\n" "" ""
+rm -rf dir*
+mkdir -p dir1/dir2
+testing "dir1/dir2/ to ./" \
+ "mv dir1/dir2/ ./ && [ ! -e dir1/dir2 -a -d dir2 ] && echo yes" \
+ "yes\n" "" ""
+rm -rf dir*
+testing "not/exists/ to ./" \
+ "mv not/exists/ ./ 2>&1 | grep -o not/exists/" \
+ "not/exists/\n" "" ""
+
touch file1 file2
chmod 400 file1 file2
testing "force over unwritable" \