uxndebug

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit 2afe2bd5ee3d3d7f42ad93d6fe51eb938e8c0cf4
parent a67888013c23b5ba833ed0eb9d03a3fc957afc54
Author: aabacchus <ben@bvnf.space>
Date:   Mon,  6 Jun 2022 00:21:01 +0100

highlight the guilty token in uxnsolve

Diffstat:
Muxnsolve | 19+++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/uxnsolve b/uxnsolve @@ -44,6 +44,21 @@ is_integer "$token" || { exit 1 } +print_highlighted() { + index="$1" + shift + j=1 + for token; do + if [ "$j" -eq "$index" ]; then + printf " \033[1;31m%s\033[m" "$token" + else + printf " %s" "$token" + fi + j="$((j + 1))" + done + printf "\n" +} + i=0 lineno=0 while read -r line; do @@ -53,8 +68,8 @@ while read -r line; do set -- $line i="$((i + $#))" [ "$i" -ge "$token" ] && { - printf "line %d: %s\n" "$lineno" "$line" - # TODO: highlight the individual token? + printf "line %d: " "$lineno" + print_highlighted "$(($# - i + token))" "$@" break } done < "$source_file"