Gentoo Archives: gentoo-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-dev@l.g.o, Ulrich Mueller <ulm@g.o>
Subject: Re: [gentoo-dev] RFC: eutils.eclass: More reliable return status for e*_clean.
Date: Fri, 16 Feb 2018 09:57:30
Message-Id: E27B9D74-06D4-4C9D-AAB8-513C11810F98@gentoo.org
In Reply to: [gentoo-dev] RFC: eutils.eclass: More reliable return status for e*_clean. by Ulrich Mueller
1 Dnia 16 lutego 2018 09:46:33 CET, Ulrich Mueller <ulm@g.o> napisał(a):
2 >Currently the return status of e{cvs,svn,git}_clean is not at all
3 >reliable, because only the last command in the pipeline is tested.
4 >In addition, there are two pipelines in ecvs_clean, and the exit
5 >status of the first one is completely ignored.
6 >
7 >Another issue is that xargs -0 is an extension not specified by POSIX.
8 >See patch included below, fixing both problems. (Note that this is
9 >close to the implementation originally proposed in bug 210708 [1].)
10 >
11 >Should we take this as an opportunity to split off these three
12 >functions into their own eclass, e.g. vcs-clean.eclass?
13 >
14 >Ulrich
15 >
16 >[1] https://bugs.gentoo.org/210708
17 >
18 >
19 >From 83c0afbfb4ef0c501c65dcd8e0c9c8bd30cdd70a Mon Sep 17 00:00:00 2001
20 >From: =?UTF-8?q?Ulrich=20M=C3=BCller?= <ulm@g.o>
21 >Date: Fri, 16 Feb 2018 07:47:46 +0100
22 >Subject: [PATCH] eutils.eclass: More reliable return status for
23 >e*_clean.
24 >
25 >In ecvs_clean, combine the two find commands into one, so that the
26 >exit status of the first one won't be ignored.
27 >
28 >Also use find -exec rather then find | xargs, so we don't have to
29 >check the exit status of all commands in the pipeline.
30 >---
31 > eclass/eutils.eclass | 8 ++++----
32 > 1 file changed, 4 insertions(+), 4 deletions(-)
33 >
34 >diff --git a/eclass/eutils.eclass b/eclass/eutils.eclass
35 >index 8bbd561015ad..bce8cf1c2610 100644
36 >--- a/eclass/eutils.eclass
37 >+++ b/eclass/eutils.eclass
38 >@@ -44,8 +44,8 @@ fi
39 > # internal CVS directories. Defaults to $PWD.
40 > ecvs_clean() {
41 > [[ $# -eq 0 ]] && set -- .
42 >- find "$@" -type d -name 'CVS' -prune -print0 | xargs -0 rm -rf
43 >- find "$@" -type f -name '.cvs*' -print0 | xargs -0 rm -rf
44 >+ find "$@" \( -type d -name 'CVS' -prune -o -type f -name '.cvs*' \) \
45 >+ -exec rm -rf '{}' \+
46
47 Could you please use quotes instead of backslash escapes all the way? They're generally less confusing since escapes trigger different behavior in different contexts in bash.
48
49 > }
50 >
51 > # @FUNCTION: esvn_clean
52 >@@ -55,7 +55,7 @@ ecvs_clean() {
53 > # internal Subversion directories. Defaults to $PWD.
54 > esvn_clean() {
55 > [[ $# -eq 0 ]] && set -- .
56 >- find "$@" -type d -name '.svn' -prune -print0 | xargs -0 rm -rf
57 >+ find "$@" -type d -name '.svn' -prune -exec rm -rf '{}' \+
58 > }
59 >
60 > # @FUNCTION: egit_clean
61 >@@ -65,7 +65,7 @@ esvn_clean() {
62 > # contains internal Git directories. Defaults to $PWD.
63 > egit_clean() {
64 > [[ $# -eq 0 ]] && set -- .
65 >- find "$@" -type d -name '.git*' -prune -print0 | xargs -0 rm -rf
66 >+ find "$@" -type d -name '.git*' -prune -exec rm -rf '{}' \+
67 > }
68 >
69 > # @FUNCTION: emktemp
70
71
72 --
73 Best regards,
74 Michał Górny (by phone)

Replies