tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: cp -i might violate POSIX



On Sat, Mar 05, 2016 at 01:41:32AM +0100, Timo Buhrmester wrote:
 > >From src/bin/cp/cp.c:
 > >	while ((ch = getopt(argc, argv, "HLNPRfailprv")) != -1) 
 > >		[...]
 > >		case 'i':
 > >			iflag = isatty(fileno(stdin));
 > The -i in cp -i is ignored if standard input isn't a tty.
 > 
 > This breaks doing something along the lines of ``yes n | cp -i [...]''
 > (obviously overwriting files that weren't supposed to be overwritten,
 > as well was rendering the only way to stop cp from overwriting existing
 > files ineffective in scripts)
 > 
 > Our man page also doesn't mention this twist.

eek that should be fixed immediately!

(fortunately it looks like ln and mv don't have this rubbish)

-- 
David A. Holland
dholland%netbsd.org@localhost


Home | Main Index | Thread Index | Old Index