1 |
Bug: https://bugs.gentoo.org/744880 |
2 |
Signed-off-by: Sam James <sam@g.o> |
3 |
--- |
4 |
eclass/edo.eclass | 34 ++++++++++++++++++++++++++++++++++ |
5 |
1 file changed, 34 insertions(+) |
6 |
create mode 100644 eclass/edo.eclass |
7 |
|
8 |
diff --git a/eclass/edo.eclass b/eclass/edo.eclass |
9 |
new file mode 100644 |
10 |
index 000000000000..fc025ddf4503 |
11 |
--- /dev/null |
12 |
+++ b/eclass/edo.eclass |
13 |
@@ -0,0 +1,34 @@ |
14 |
+# Copyright 2022 Gentoo Authors |
15 |
+# Distributed under the terms of the GNU General Public License v2 |
16 |
+ |
17 |
+# @ECLASS: edo.class |
18 |
+# @MAINTAINER: |
19 |
+# QA Team <qa@g.o> |
20 |
+# @AUTHOR: |
21 |
+# Sam James <sam@g.o> |
22 |
+# @SUPPORTED_EAPIS: 8 |
23 |
+# @BLURB: Convenience function to run commands verbosely and die on failure |
24 |
+# @DESCRIPTION: |
25 |
+# This eclass provides the 'edo' command which dies (exits) on failure |
26 |
+# and logs the command used verbosely. |
27 |
+# |
28 |
+ |
29 |
+case ${EAPI:-0} in |
30 |
+ 8) ;; |
31 |
+ *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; |
32 |
+esac |
33 |
+ |
34 |
+if [[ -z ${_EDO_ECLASS} ]] ; then |
35 |
+ _EDO_CLASS=1 |
36 |
+ |
37 |
+# @FUNCTION: edo |
38 |
+# @USAGE: command [arg1 [arg2 ...]] |
39 |
+# @DESCRIPTION: |
40 |
+# Executes 'command' with any given arguments and exits on failure unless |
41 |
+# called under 'nonfatal'. |
42 |
+edo() { |
43 |
+ elog "$@" |
44 |
+ "$@" || die -n "Failed to run command: $@ failed" |
45 |
+} |
46 |
+ |
47 |
+fi |
48 |
-- |
49 |
2.35.1 |