commit:     d3e39fba9cafdc78a92363702bcc117bf6c30a9e
Author:     Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Thu May 16 02:32:10 2024 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Thu May 16 02:36:54 2024 +0000
URL:        
https://gitweb.gentoo.org/proj/gentoo-functions.git/commit/?id=d3e39fba

Declare eerror(), einfo() and ewarn() dynamically

Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>

 functions.sh | 30 +++++++++---------------------
 1 file changed, 9 insertions(+), 21 deletions(-)

diff --git a/functions.sh b/functions.sh
index dfbbe31..60fa2fa 100644
--- a/functions.sh
+++ b/functions.sh
@@ -56,12 +56,16 @@ eend()
 }
 
 #
-#    show an error message (with a newline) and log it
+#   Declare the eerror, einfo and ewarn functions. These wrap errorn, einfon 
and
+#   ewarnn respectively, the difference being that a newline is appended.
 #
-eerror()
-{
-       eerrorn "${*}${genfun_newline}"
-}
+for _ in eerror einfo ewarn; do
+       eval "
+               $_ () {
+                       ${_}n \"\${*}\${genfun_newline}\"
+               }
+       "
+done
 
 #
 #    show an error message (without a newline) and log it
@@ -86,14 +90,6 @@ eindent()
        _esetdent "$(( ${#genfun_indent} + $1 ))"
 }
 
-#
-#    show an informative message (with a newline)
-#
-einfo()
-{
-       einfon "${*}${genfun_newline}"
-}
-
 #
 #    show an informative message (without a newline)
 #
@@ -138,14 +134,6 @@ esyslog()
        fi
 }
 
-#
-#    show a warning message (with a newline) and log it
-#
-ewarn()
-{
-       ewarnn "${*}${genfun_newline}"
-}
-
 #
 #    show a warning message (without a newline) and log it
 #

Reply via email to