Gentoo Archives: gentoo-dev

From: "Petteri Räty" <betelgeuse@g.o>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] Usage of cp -i to prevent overwriting upstream files
Date: Tue, 20 Jan 2009 19:38:42
Message-Id: 497627F1.5060704@gentoo.org
In Reply to: Re: [gentoo-dev] Usage of cp -i to prevent overwriting upstream files by Ferris McCormick
1 Ferris McCormick wrote:
2 > On Tue, 2009-01-20 at 21:04 +0200, Petteri Räty wrote:
3 >> Many times upstream Java projects don't include build.xml files or
4 >> proper build systems so we include build.xml files in $FILESDIR. In case
5 >> upstream some day adds one we usually use cp -i to detect if upstream
6 >> adds this file in new versions. If devs do their job properly, this will
7 >> never show to users. On #gentoo-dev at least grobian and darkside did
8 >> not like this and proposed using test and die instead. If we think that
9 >> cp -i is not acceptable, this should be made a function to avoid code
10 >> duplication in my opinion. Here's a suggestion:
11 >>
12 >> function cp-no-replace() {
13 >> debug-print-function ${FUNCNAME} $*
14 >>
15 >> [[ ${#} != 2 ]] && die "${FUNCNAME} takes two arguments"
16 >> [[ -e ${2} ]] && die "die target exists"
17 >>
18 >> cp "${1}" "${2}" || die "cp failed"
19 >> }
20 >>
21 >> So do you think:
22 >> a) cp -i is fine
23 >
24 > Fine with me
25 >
26 >> b) this function should be added to eutils
27 >
28 > I don't like this one ---
29 > [[ ${#} != 2 ]] && die "${FUNCNAME} takes two arguments"
30 > [[ -e ${2} ]] && die "die target exists"
31 >
32 > How does the user recover from that? I would become irate if a build
33 > died without giving some useful indication the problem.
34 >
35
36 You did not understand the issue if you are fine with a) but then make
37 this statement. a) would surely be even more confusing to the user.
38
39 Regards,
40 Petteri

Attachments

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

Replies

Subject Author
Re: [gentoo-dev] Usage of cp -i to prevent overwriting upstream files Ferris McCormick <fmccor@g.o>