summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2017-08-12 20:17:10 -0400
committerTavian Barnes <tavianator@tavianator.com>2017-08-12 20:17:10 -0400
commit1022d5a52cfa53eb527d316ca5c06e0a3eb2c42c (patch)
tree7566ca7d77293ae6001601a911a1537d76f9ed89
parentacd7f7ed437793e7c67ecd869cfac32a87c1ec52 (diff)
downloadbfs-1022d5a52cfa53eb527d316ca5c06e0a3eb2c42c.tar.xz
tests: Add some syntax highlighting to --verbose
-rwxr-xr-xtests.sh25
1 files 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
}