Gentoo Archives: gentoo-dev

From: "Petteri Räty" <betelgeuse@g.o>
To: gentoo-dev@l.g.o
Subject: [gentoo-dev] Usage of cp -i to prevent overwriting upstream files
Date: Tue, 20 Jan 2009 19:04:42
Message-Id: 4976205A.5030600@gentoo.org
1 Many times upstream Java projects don't include build.xml files or
2 proper build systems so we include build.xml files in $FILESDIR. In case
3 upstream some day adds one we usually use cp -i to detect if upstream
4 adds this file in new versions. If devs do their job properly, this will
5 never show to users. On #gentoo-dev at least grobian and darkside did
6 not like this and proposed using test and die instead. If we think that
7 cp -i is not acceptable, this should be made a function to avoid code
8 duplication in my opinion. Here's a suggestion:
9
10 function cp-no-replace() {
11 debug-print-function ${FUNCNAME} $*
12
13 [[ ${#} != 2 ]] && die "${FUNCNAME} takes two arguments"
14 [[ -e ${2} ]] && die "die target exists"
15
16 cp "${1}" "${2}" || die "cp failed"
17 }
18
19 So do you think:
20 a) cp -i is fine
21 b) this function should be added to eutils
22 c) keep it restricted to java eclasses
23 d) something else
24
25 Regards,
26 Petteri

Attachments

File name MIME type
signature.asc application/pgp-signature

Replies