diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2017-08-12 20:17:10 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2017-08-12 20:17:10 -0400 |
commit | 1022d5a52cfa53eb527d316ca5c06e0a3eb2c42c (patch) | |
tree | 7566ca7d77293ae6001601a911a1537d76f9ed89 | |
parent | acd7f7ed437793e7c67ecd869cfac32a87c1ec52 (diff) | |
download | bfs-1022d5a52cfa53eb527d316ca5c06e0a3eb2c42c.tar.xz |
tests: Add some syntax highlighting to --verbose
-rwxr-xr-x | tests.sh | 25 |
1 files changed, 22 insertions, 3 deletions
@@ -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 } |