From 1022d5a52cfa53eb527d316ca5c06e0a3eb2c42c Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Sat, 12 Aug 2017 20:17:10 -0400 Subject: tests: Add some syntax highlighting to --verbose --- tests.sh | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/tests.sh b/tests.sh index 1517bda..9dc0c65 100755 --- a/tests.sh +++ b/tests.sh @@ -460,11 +460,30 @@ fi function bfs_verbose() { if [ "$VERBOSE" ]; then if [ -t 3 ]; then - printf '\033[1;32m%s\033[0m ' $BFS >&3 - echo "$@" >&3 + printf '\033[1;32m%q\033[0m ' $BFS >&3 + + local expr_started= + for arg; do + if [[ $arg == -[A-Z]* ]]; then + printf '\033[1;36m%q\033[0m ' "$arg" >&3 + elif [[ $arg == [\(!] || $arg == -[ao] || $arg == -and || $arg == -or || $arg == -not ]]; then + expr_started=yes + printf '\033[1;31m%q\033[0m ' "$arg" >&3 + elif [[ $expr_started && $arg == [\),] ]]; then + printf '\033[1;31m%q\033[0m ' "$arg" >&3 + elif [[ $arg == -?* ]]; then + expr_started=yes + printf '\033[1;34m%q\033[0m ' "$arg" >&3 + elif [ "$expr_started" ]; then + printf '\033[1m%q\033[0m ' "$arg" >&3 + else + printf '\033[1;35m%q\033[0m ' "$arg" >&3 + fi + done else - echo $BFS "$@" >&3 + printf '%q ' $BFS "$@" >&3 fi + printf '\n' >&3 fi } -- cgit v1.2.3