commit:     747923957049eb32c2a7b6aa5e52c12e6dcc561e
Author:     Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Mon Feb 13 03:52:24 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Mon Feb 13 21:35:40 2023 +0000
URL:        
https://gitweb.gentoo.org/proj/gentoo-functions.git/commit/?id=74792395

Guard against errexit in the v-prefixed functions

This also improves the structure of some of them, slightly.

Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
Signed-off-by: Sam James <sam <AT> gentoo.org>

 functions.sh | 43 +++++++++++++++++++++++++++++++------------
 1 file changed, 31 insertions(+), 12 deletions(-)

diff --git a/functions.sh b/functions.sh
index 2361808..3c782cd 100644
--- a/functions.sh
+++ b/functions.sh
@@ -294,52 +294,71 @@ ewend()
 }
 
 # v-e-commands honor EINFO_VERBOSE which defaults to no.
-# The condition is negated so the return value will be zero.
 veinfo()
 {
-       yesno "${EINFO_VERBOSE}" && einfo "$@"
+       if yesno "${EINFO_VERBOSE}"; then
+               einfo "$@"
+       fi
 }
 
 veinfon()
 {
-       yesno "${EINFO_VERBOSE}" && einfon "$@"
+       if yesno "${EINFO_VERBOSE}"; then
+               einfon "$@"
+       fi
 }
 
 vewarn()
 {
-       yesno "${EINFO_VERBOSE}" && ewarn "$@"
+       if yesno "${EINFO_VERBOSE}"; then
+               ewarn "$@"
+       fi
 }
 
 veerror()
 {
-       yesno "${EINFO_VERBOSE}" && eerror "$@"
+       if yesno "${EINFO_VERBOSE}"; then
+               eerror "$@"
+       fi
 }
 
 vebegin()
 {
-       yesno "${EINFO_VERBOSE}" && ebegin "$@"
+       if yesno "${EINFO_VERBOSE}"; then
+               ebegin "$@"
+       fi
 }
 
 veend()
 {
-       yesno "${EINFO_VERBOSE}" && { eend "$@"; return $?; }
-       return "${1:-0}"
+       if yesno "${EINFO_VERBOSE}"; then
+               eend "$@"
+       else
+               return "${1:-0}"
+       fi
 }
 
 vewend()
 {
-       yesno "${EINFO_VERBOSE}" && { ewend "$@"; return $?; }
-       return "${1:-0}"
+       if yesno "${EINFO_VERBOSE}"; then
+               ewend "$@"
+       else
+               return "${1:-0}"
+       fi
 }
 
 veindent()
 {
-       yesno "${EINFO_VERBOSE}" && eindent
+       if yesno "${EINFO_VERBOSE}"; then
+               eindent
+       fi
 }
 
 veoutdent()
 {
-       yesno "${EINFO_VERBOSE}" && eoutdent
+       if yesno "${EINFO_VERBOSE}"; then
+               eoutdent
+       fi
 }
 
 #

Reply via email to