From: Richard W.M. Jones Date: Sun, 12 Jan 2020 22:00:58 +0000 (+0000) Subject: stdlib: Change print colour functions so they are atomic. X-Git-Tag: v'0.2'~13 X-Git-Url: http://git.annexia.org/?a=commitdiff_plain;h=f2758f9e55a2b4d4a30e362f2b7a7a51cd515c78;p=goals.git stdlib: Change print colour functions so they are atomic. --- diff --git a/Goalfile.in b/Goalfile.in index 32ff7b5..0fd2b5b 100644 --- a/Goalfile.in +++ b/Goalfile.in @@ -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 } diff --git a/stdlib/prelude.sh b/stdlib/prelude.sh index 254c380..fcd1bac 100644 --- a/stdlib/prelude.sh +++ b/stdlib/prelude.sh @@ -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" }