cp(1) bug

utzoo!decvax!ittvax!swatt utzoo!decvax!ittvax!swatt
Wed Nov 25 19:37:27 AEST 1981


Wed Nov 25 19:15:37 EST 1981 (reported by swatt)
[ ]	"cp" when faced with a source argument which is a
	directory copies the data of the directory file into
	a plain file in the destination area.  This is
	obnoxious; either it should allow recursive copying
	of directory trees or it should ignore directory
	source arguments.  Fix is:
	________________________________________________________
	cp /usr/src/cmd/cp.c /tmp/upd.$$.tmp ; chmod +w /tmp/upd.$$.tmp
	ed - /tmp/upd.$$.tmp <<\!xxFUNNYxx
	71a
		/* Is source a directory? if so, skip it.
		 * Probably more reasonable action would be to
		 * copy contents of directory if -r flag set
		 */
		if ((mode&S_IFMT) == S_IFDIR) {
			close (fold);
			fprintf (stderr, "%s is a directory (ignored)\n", from);
			return;
		}
	.
	1c
	static char *sccsid = "@(#)cp.c	4.2 (ITT) 11/19/81";
	.
	w
	q
	!xxFUNNYxx
	diff /usr/src/cmd/cp.c /tmp/upd.$$.tmp >/tmp/upd.$$.dif
	if cmp - /tmp/upd.$$.dif <<\!xxFUNNYxx
	1c1
	< static char *sccsid = "@(#)cp.c	4.1 (Berkeley) 10/1/80";
	---
	> static char *sccsid = "@(#)cp.c	4.2 (ITT) 11/19/81";
	71a72,80
	> 	/* Is source a directory? if so, skip it.
	> 	 * Probably more reasonable action would be to
	> 	 * copy contents of directory if -r flag set
	> 	 */
	> 	if ((mode&S_IFMT) == S_IFDIR) {
	> 		close (fold);
	> 		fprintf (stderr, "%s is a directory (ignored)\n", from);
	> 		return;
	> 	}
	!xxFUNNYxx
	then
		: 'compare equal, ok'
		rm -f cp.c
		cp /tmp/upd.$$.tmp cp.c ; chmod a-w cp.c
	else
		echo "Old source file not same version;" \
			"use diff listings by hand"
	fi
	rm -f /tmp/upd.$$.tmp /tmp/upd.$$.dif
	________________________________________________________
	[ /bin/cp:
		cp.c	4.1 (Berkeley) 10/1/80 ]



More information about the Comp.bugs.4bsd.ucb-fixes mailing list