aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-06-19 09:41:05 +0200
committerDanilo M. <danix@danix.xyz>2026-06-19 09:41:05 +0200
commit942f2fe96bcfdba0b709cc5dded3852d4c5ed239 (patch)
tree98aa073ef21ddaadcea96a2838d910bfe457ecab
parentdcd151797c2777fcc061920207b17342b72420e4 (diff)
downloadmkhintfile-942f2fe96bcfdba0b709cc5dded3852d4c5ed239.tar.gz
mkhintfile-942f2fe96bcfdba0b709cc5dded3852d4c5ed239.zip
feat: highlight hint rows whose version matches SBo .info in -l
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
-rwxr-xr-xmkhint27
-rwxr-xr-xtests/mkhint_test.sh31
2 files changed, 56 insertions, 2 deletions
diff --git a/mkhint b/mkhint
index 38e758c..89bcdb3 100755
--- a/mkhint
+++ b/mkhint
@@ -32,6 +32,7 @@ VERSION=""
HINT_FILE=""
NEW_HINT_FILE=""
DELETE_HINT_FILES=()
+MATCHED_PKGS=()
COMMAND=""
NO_DL=0
@@ -85,12 +86,23 @@ list_hint_files() {
exit 2
fi
+ # Color only on a TTY, or when forced for tests. tput optional.
+ local c_on="" c_off=""
+ if [[ -n "$MKHINT_FORCE_COLOR" || -t 1 ]]; then
+ if command -v tput &>/dev/null && tput setaf 3 &>/dev/null; then
+ c_on=$(tput setaf 3); c_off=$(tput sgr0)
+ else
+ c_on=$'\033[33m'; c_off=$'\033[0m'
+ fi
+ fi
+
echo "Hint files in: $HINT_DIR"
echo "======================================================="
printf "%-40s %10s %10s %-20s %s\n" "File" "HintVer" "SBOVer" "Category" "Created"
echo "-------------------------------------------------------"
- local count=0
+ MATCHED_PKGS=()
+ local count=0 matched=0
for file in "$HINT_DIR"/*.hint; do
if [[ -f "$file" ]]; then
local VER=$(grep "^VERSION" "$file" |cut -d '"' -f2)
@@ -105,7 +117,15 @@ list_hint_files() {
category=$(basename "$(dirname "$(dirname "$info_file")")")
fi
local date=$(stat -c "%y" "$file" | cut -d'.' -f1)
- printf "%-40s %10s %10s %-20s %s\n" "$name" "$VER" "$SBO_VER" "$category" "$date"
+ local row
+ row=$(printf "%-40s %10s %10s %-20s %s" "$name" "$VER" "$SBO_VER" "$category" "$date")
+ if [[ -n "$VER" && "$VER" == "$SBO_VER" ]]; then
+ printf "%s%s%s\n" "$c_on" "$row" "$c_off"
+ MATCHED_PKGS+=("$pkg")
+ matched=$((matched + 1))
+ else
+ printf "%s\n" "$row"
+ fi
count=$((count + 1))
fi
done
@@ -116,6 +136,9 @@ list_hint_files() {
echo "======================================================="
echo "Total: $count file(s)"
+ if [[ $matched -gt 0 && -n "$c_on" ]]; then
+ echo "(highlighted = hint version matches SBo .info)"
+ fi
}
# Validate wget availability
diff --git a/tests/mkhint_test.sh b/tests/mkhint_test.sh
index dd88c05..e435eff 100755
--- a/tests/mkhint_test.sh
+++ b/tests/mkhint_test.sh
@@ -744,6 +744,37 @@ EOF
run_mkhint -C curl < <(printf 'Y\nn\n')
assert_contains "relative-path keyfile found → curl updated" "$MOCK_HINT/curl.hint" 'VERSION="8.9.0"'
+# ── T36: -l highlights rows where hint version == SBo version ─────────────────
+echo ""
+echo "T36: -l highlights matching version rows, plain row for mismatch"
+rm -f "$MOCK_HINT"/*.hint "$MOCK_HINT"/*.bak 2>/dev/null
+# curl matches its .info (8.5.0); clion differs (hint 9.9.9 vs .info 2025.3)
+cat > "$MOCK_HINT/curl.hint" << 'EOF'
+VERSION="8.5.0"
+ARCH="x86_64"
+DOWNLOAD="https://curl.se/download/curl-8.5.0.tar.gz"
+MD5SUM="abc123def456abc123def456abc123de"
+EOF
+cat > "$MOCK_HINT/clion.hint" << 'EOF'
+VERSION="9.9.9"
+ARCH="x86_64"
+DOWNLOAD="UNSUPPORTED"
+MD5SUM=""
+EOF
+# force color so the highlight is observable through the $(...) pipe
+out=$(MKHINT_FORCE_COLOR=1 run_mkhint -l 2>&1)
+# matched curl row carries the color start code (ESC[33m); legend present
+echo "$out" | grep -q $'\033\[33m.*curl.hint' \
+ && { echo " PASS: curl row highlighted"; (( PASS++ )); } \
+ || { echo " FAIL: curl row not highlighted"; echo "$out" | cat -v | sed 's/^/ /'; (( FAIL++ )); ERRORS+=("T36 highlight"); }
+echo "$out" | grep -q "highlighted = hint version matches" \
+ && { echo " PASS: legend shown"; (( PASS++ )); } \
+ || { echo " FAIL: legend missing"; (( FAIL++ )); ERRORS+=("T36 legend"); }
+# clion row must NOT carry the color start code
+echo "$out" | grep "clion.hint" | grep -q $'\033\[33m' \
+ && { echo " FAIL: clion wrongly highlighted"; (( FAIL++ )); ERRORS+=("T36 false hl"); } \
+ || { echo " PASS: clion row plain"; (( PASS++ )); }
+
# ─── SUMMARY ──────────────────────────────────────────────────────────────────
teardown