Bug: https://bugs.gentoo.org/744880
Signed-off-by: Sam James <sam@gentoo.org>
---
eclass/edo.eclass | 46 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 46 insertions(+)
create mode 100644 eclass/edo.eclass
diff --git a/eclass/edo.eclass b/eclass/edo.eclass
new file mode 100644
index 000000000000..7b4ae04c43ab
--- /dev/null
+++ b/eclass/edo.eclass
@@ -0,0 +1,46 @@
+# Copyright 2022 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# @ECLASS: edo.class
+# @MAINTAINER:
+# QA Team <qa@gentoo.org>
+# @AUTHOR:
+# Sam James <sam@gentoo.org>
+# @SUPPORTED_EAPIS: 7 8
+# @BLURB: Convenience function to run commands verbosely and die on failure +# @DESCRIPTION:
+# This eclass provides the 'edo' command, and an 'edob' variant for ebegin/eend,
+# which dies (exits) on failure and logs the command used verbosely.
+#
+
+case ${EAPI:-0} in
+ 7|8) ;;
+ *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
+esac
+
+if [[ -z ${_EDO_ECLASS} ]] ; then
+ _EDO_CLASS=1
+
+# @FUNCTION: edo
+# @USAGE: <command> [<args>...]
+# @DESCRIPTION:
+# Executes 'command' with any given arguments and exits on failure unless
+# called under 'nonfatal'.
+edo() {
+ elog "$@"
+ "$@" || die -n "Failed to run command: $@ failed"
+}
+
+# @FUNCTION: edob
+# @USAGE: <command> [<args>...]
+# @DESCRIPTION:
+# Executes 'command' with ebegin & eend with any given arguments and exits +# on failure unless called under 'nonfatal'.
+# Intended for single commands, otherwise regular ebegin/eend should be used.
+edob() {
+ ebegin "Running $@"
+ "$@"
+ eend $? || die -n "$@ failed"
+}
+
+fi
+# @USAGE: <command> [<args>...]
+# @DESCRIPTION:
+# Executes 'command' with any given arguments and exits on failure unless +# called under 'nonfatal'.
+edo() {
+ elog "$@"
einfo?
e.g. if using edo to replace stuff like
# ./configure is not real autoconf!
local cmd=(
./configure
--args
${EXTRA_ECONF}
)
echo ${cmd[*]}"
"${cmd[@]}" || die "cmd failed: ${cmd[*]}"
Bug: https://bugs.gentoo.org/744880
Signed-off-by: Sam James <sam@gentoo.org>
---
eclass/edo.eclass | 46 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 46 insertions(+)
create mode 100644 eclass/edo.eclass
diff --git a/eclass/edo.eclass b/eclass/edo.eclass
new file mode 100644
index 000000000000..7b4ae04c43ab
--- /dev/null
+++ b/eclass/edo.eclass
@@ -0,0 +1,46 @@
+# Copyright 2022 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# @ECLASS: edo.class
+# @MAINTAINER:
+# QA Team <qa@gentoo.org>
+# @AUTHOR:
+# Sam James <sam@gentoo.org>
+# @SUPPORTED_EAPIS: 7 8
+# @BLURB: Convenience function to run commands verbosely and die on failure +# @DESCRIPTION:
+# This eclass provides the 'edo' command, and an 'edob' variant for ebegin/eend,
+# which dies (exits) on failure and logs the command used verbosely.
+#
+
+case ${EAPI:-0} in
+ 7|8) ;;
+ *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
+esac
+
+if [[ -z ${_EDO_ECLASS} ]] ; then
+ _EDO_CLASS=1
+
+# @FUNCTION: edo
+# @USAGE: <command> [<args>...]
+# @DESCRIPTION:
+# Executes 'command' with any given arguments and exits on failure unless
+# called under 'nonfatal'.
+edo() {
+ elog "$@"
+ "$@" || die -n "Failed to run command: $@ failed"
+}
+
+# @FUNCTION: edob
+# @USAGE: <command> [<args>...]
+# @DESCRIPTION:
+# Executes 'command' with ebegin & eend with any given arguments and exits +# on failure unless called under 'nonfatal'.
+# Intended for single commands, otherwise regular ebegin/eend should be used.
+edob() {
+ ebegin "Running $@"
+ "$@"
+ eend $? || die -n "$@ failed"
+}
+
+fi
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 546 |
Nodes: | 16 (2 / 14) |
Uptime: | 38:32:33 |
Calls: | 10,392 |
Files: | 14,064 |
Messages: | 6,417,176 |