From fab8d674b398231333f39fab7da821fb82212069 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Sun, 23 Aug 2020 23:04:17 -0500 Subject: mv should only prompt for file being unwriteable when stdin is a tty. --- toys/posix/cp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'toys') diff --git a/toys/posix/cp.c b/toys/posix/cp.c index 09e5701f..cd8a7b15 100644 --- a/toys/posix/cp.c +++ b/toys/posix/cp.c @@ -432,7 +432,7 @@ void cp_main(void) // 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. - if (exists && (FLAG(i) || !(st.st_mode & 0222))) { + if (exists && (FLAG(i) || (!(st.st_mode & 0222) && isatty(0)))) { fprintf(stderr, "%s: overwrite '%s'", toys.which->name, TT.destname); if (!yesno(0)) rc = 0; else unlink(TT.destname); -- cgit v1.2.3