commit: e4eab7040c9b36f5ebfc9eb0880cfd39735e4a85
Author: Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Thu May 16 01:51:13 2024 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Thu May 16 01:53:05 2024 +0000
URL:
https://gitweb.gentoo.org/proj/gentoo-functions.git/commit/?id=e4eab704
Declare some of the v-prefixed functions dynamically
Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
functions.sh | 62 ++++++++++++++----------------------------------------------
1 file changed, 14 insertions(+), 48 deletions(-)
diff --git a/functions.sh b/functions.sh
index 8561eb3..6647c67 100644
--- a/functions.sh
+++ b/functions.sh
@@ -272,12 +272,20 @@ is_older_than()
read -r _
}
-vebegin()
-{
- if yesno "${EINFO_VERBOSE}"; then
- ebegin "$@"
- fi
-}
+#
+# Declare the vebegin, veerror, veindent, veinfo, veinfon, veoutdent and
+# vewarn functions. These differ from their non-v-prefixed counterparts in
+# that they only have an effect where EINFO_VERBOSE is set as a truthy value.
+#
+for _ in vebegin veerror veindent veinfo veinfon veoutdent vewarn; do
+ eval "
+ $_ () {
+ if yesno \"\${EINFO_VERBOSE}\"; then
+ ${_#v} \"\$@\"
+ fi
+ }
+ "
+done
veend()
{
@@ -290,48 +298,6 @@ veend()
fi
}
-veerror()
-{
- if yesno "${EINFO_VERBOSE}"; then
- eerror "$@"
- fi
-}
-
-veindent()
-{
- if yesno "${EINFO_VERBOSE}"; then
- eindent "$@"
- fi
-}
-
-veinfo()
-{
- if yesno "${EINFO_VERBOSE}"; then
- einfo "$@"
- fi
-}
-
-veinfon()
-{
- if yesno "${EINFO_VERBOSE}"; then
- einfon "$@"
- fi
-}
-
-veoutdent()
-{
- if yesno "${EINFO_VERBOSE}"; then
- eoutdent "$@"
- fi
-}
-
-vewarn()
-{
- if yesno "${EINFO_VERBOSE}"; then
- ewarn "$@"
- fi
-}
-
vewend()
{
if yesno "${EINFO_VERBOSE}"; then