aboutsummaryrefslogtreecommitdiff
path: root/toys/posix/cp.c
diff options
context:
space:
mode:
Diffstat (limited to 'toys/posix/cp.c')
-rw-r--r--toys/posix/cp.c2
1 files changed, 2 insertions, 0 deletions
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.