[arch-projects] [netctl][PATCH] beautify error output

Jouke Witteveen j.witteveen at gmail.com
Thu Oct 24 05:16:27 EDT 2013


Also: tag error messages as systemd error messages when the messages are
not directed to the terminal.

Signed-off-by: Jouke Witteveen <j.witteveen at gmail.com>
---
 src/lib/globals | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/lib/globals b/src/lib/globals
index a2a281f..f31beac 100644
--- a/src/lib/globals
+++ b/src/lib/globals
@@ -15,7 +15,12 @@ report_notice() {
 }
 
 report_error() {
-    echo "$*"
+    local prefix="<3>" suffix=""
+    if [[ -t 2 ]]; then
+        prefix=$(tput bold; tput setaf 1)
+        suffix=$(tput sgr0)
+    fi
+    echo "$prefix$*$suffix" >&2
 }
 
 report_debug() {
@@ -23,7 +28,7 @@ report_debug() {
 }
 
 exit_error() {
-    report_error "$@" >&2
+    report_error "$@"
     exit 1
 }
 
-- 
1.8.4.1



More information about the arch-projects mailing list