stdlib: Change print colour functions so they are atomic.
authorRichard W.M. Jones <rjones@redhat.com>
Sun, 12 Jan 2020 22:00:58 +0000 (22:00 +0000)
committerRichard W.M. Jones <rjones@redhat.com>
Sun, 12 Jan 2020 22:01:17 +0000 (22:01 +0000)
Goalfile.in
stdlib/prelude.sh

index 32ff7b5..0fd2b5b 100644 (file)
@@ -147,15 +147,9 @@ goal test (name) = @{
     t=`basename %name`
     cd tests
     if ../run ./$t > $t.log 2>&1; then
-        start_green
-        echo -n "PASS: "
-        end_colour
-        echo $t
+        print_green "PASS:" $t
     else
-        start_red
-        echo -n "FAIL: "
-        end_colour
-        echo $t
+        print_red "FAIL:" $t
         exit 1
     fi
 }
index 254c380..fcd1bac 100644 (file)
@@ -27,22 +27,13 @@ function quoted_string ()
     echo -n "\"$1\""
 }
 
-# For printing strings in different colours, use these functions.
-function start_red ()
+# For printing strings in different colours.
+function print_red ()
 {
-    echo -ne "\x1b[1;31m"
+    echo -e "\x1b[1;31m$@\x1b[0m"
 }
 
-function start_green ()
+function print_green ()
 {
-    echo -ne "\x1b[0;32m"
-}
-
-function end_colour ()
-{
-    echo -ne "\x1b[0m"
-}
-function end_color ()
-{
-    echo -ne "\x1b[0m"
+    echo -e "\x1b[0;32m$@\x1b[0m"
 }