aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xtests/mv.test7
-rw-r--r--toys/posix/cp.c2
2 files changed, 8 insertions, 1 deletions
diff --git a/tests/mv.test b/tests/mv.test
index 53fc9992..030e9ccc 100755
--- a/tests/mv.test
+++ b/tests/mv.test
@@ -96,3 +96,10 @@ touch file1 file2
testing "Move -n file new_file (exist)" "mv -n file1 file2 &&
[ -e file1 -a -e file2 ] && echo 'yes'" "yes\n" "" ""
rm -f file*
+
+touch file1 file2
+chmod 400 file1 file2
+testing "Move file over unwritable file with no stdin" \
+ "</dev/null mv file2 file1 && [ -e file -a ! -e file2 ] && echo 'yes'" \
+ "yes\n" "" ""
+rm -f file*
diff --git a/toys/posix/cp.c b/toys/posix/cp.c
index d5e92f20..5a55f40b 100644
--- a/toys/posix/cp.c
+++ b/toys/posix/cp.c
@@ -382,7 +382,7 @@ void cp_main(void)
{
fprintf(stderr, "%s: overwrite '%s'", toys.which->name, TT.destname);
if (!yesno("", 1)) rc = 0;
- else unlink(src);
+ else unlink(TT.destname);
}
}