Follow the behavior as specified in POSIX:

if (exists AND (NOT f_option) AND
	((not_writable AND input_is_terminal) OR i_option))
		prompt

in particular, add the test for input_is_terminal

PR:		bin/173039
Submitted by:	Mark Johnston <markjdb@gmail.com>
Approved by:	cperciva
MFC after:	3 days
This commit is contained in:
Eitan Adler 2012-11-15 15:05:51 +00:00
parent 1ca2e4234e
commit b7d1b37159
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=243072

View File

@ -199,7 +199,7 @@ do_move(const char *from, const char *to)
} else if (iflg) {
(void)fprintf(stderr, "overwrite %s? %s", to, YESNO);
ask = 1;
} else if (access(to, W_OK) && !stat(to, &sb)) {
} else if (access(to, W_OK) && !stat(to, &sb) && isatty(STDIN_FILENO)) {
strmode(sb.st_mode, modep);
(void)fprintf(stderr, "override %s%s%s/%s for %s? %s",
modep + 1, modep[9] == ' ' ? "" : " ",