aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2016-03-30 03:20:13 -0500
committerRob Landley <rob@landley.net>2016-03-30 03:20:13 -0500
commit9b93dd397b4a00063073fdbd59b181a508470e70 (patch)
tree664cf7dfd0ba4160ada3a2b60912c8fcf2120563
parent7a0186cc2abf6ef9af3f26416dba7e920d100b42 (diff)
downloadtoybox-9b93dd397b4a00063073fdbd59b181a508470e70.tar.gz
Whitespace and comment.
-rwxr-xr-xtests/mv.test5
-rw-r--r--toys/posix/cp.c2
2 files changed, 7 insertions, 0 deletions
diff --git a/tests/mv.test b/tests/mv.test
index b699d017..036fd48e 100755
--- a/tests/mv.test
+++ b/tests/mv.test
@@ -1,5 +1,10 @@
#!/bin/bash
+# TODO: needs root to mount tmpfs to test moving across filesystems.
+# check handling of chattr +i immutable bit
+# "touch two; chmod -w two; mv one two" shouldn't prompt to delete two if
+# one doesn't exist.
+
# Copyright 2013 Robin Mittal <robinmittal.it@gmail.com>
# Copyright 2013 Divya Kothari <divya.s.kothari@gmail.com>
diff --git a/toys/posix/cp.c b/toys/posix/cp.c
index 8bcb81e6..ea1ef6f4 100644
--- a/toys/posix/cp.c
+++ b/toys/posix/cp.c
@@ -396,9 +396,11 @@ void cp_main(void)
errno = EXDEV;
if (CFG_MV && toys.which->name[0] == 'm') {
int force = toys.optflags & FLAG_f, no_clobber = toys.optflags & FLAG_n;
+
if (!force || no_clobber) {
struct stat st;
int exists = !stat(TT.destname, &st);
+
// Prompt if -i or file isn't writable. Technically "is writable" is
// more complicated (022 is not writeable by the owner, just everybody
// _else_) but I don't care.