From 9b57db37b6dca87247e30b1e5e2259094c7157b5 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Wed, 8 Jul 2026 11:51:26 +0200 Subject: fix: skip bundled-dep apply prompt when nothing changed; release v1.2.3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit After the version-aware reconcile, a --force run on an up-to-date bundle package still asked "Apply bundled-dep updates?" with nothing to apply. reconcile_bundle_deps report mode now signals whether there is anything to apply via its exit code: 2 = changes present, 0 = all current / no deps / fetch fail. The --check and --hintfile -V callers prompt only on exit 2. apply mode still returns 0. Adds T-BM24 (all-current → no prompt); 183 passed. Bump MKHINT_VERSION and man title to 1.2.3, rebuild mkhint.1.gz. Co-Authored-By: Claude Opus 4.8 --- mkhint | 42 ++++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 14 deletions(-) (limited to 'mkhint') diff --git a/mkhint b/mkhint index 2a95cf2..5fc08db 100755 --- a/mkhint +++ b/mkhint @@ -45,7 +45,7 @@ if [[ ! -d $TMP_DIR ]]; then mkdir $TMP_DIR fi -readonly MKHINT_VERSION="1.2.2" +readonly MKHINT_VERSION="1.2.3" # Variables VERSION="" @@ -578,6 +578,9 @@ fetch_manifest() { # mode = report (print only) | apply (rewrite matched changed lines + md5). # Reconciles the DOWNLOAD line's extra URLs (index >= 1) against the manifest. # The primary URL (index 0) is never touched here. Guarded for set -e. +# In report mode: returns 2 when there are changes to apply, 0 otherwise (all +# current, no deps, fetch/parse fail) so a caller can skip the apply prompt. +# apply mode always returns 0. reconcile_bundle_deps() { local pkg="$1" hint="$2" murl="$3" mode="$4" @@ -667,7 +670,10 @@ reconcile_bundle_deps() { for (( i=0; i<${#changed_idx[@]}; i++ )); do printf ' %s %s -> %s\n' "${changed_name[$i]}" "${changed_oldver[$i]}" "${changed_newver[$i]}" done - return 0 + # report mode signals "there are changes to apply" via exit 2, so the + # caller can skip the apply prompt when nothing changed. Every other + # report exit (no change, no deps, fetch fail) returns 0. + return 2 fi # apply mode: recompute md5 only for changed lines, rewrite DOWNLOAD+MD5SUM. @@ -1325,12 +1331,17 @@ check_updates() { local murl; murl=$(manifest_url_for "$pkg" "$cur") || continue echo "" echo "Bundled-dep reconcile: $pkg (manifest @ $cur)" - reconcile_bundle_deps "$pkg" "$hintpath" "$murl" report || true - local ans - read -r -p "Apply bundled-dep updates for $pkg? [Y/n] " ans - ans="${ans:-Y}" - if [[ "$ans" =~ ^[Yy]$ ]]; then - reconcile_bundle_deps "$pkg" "$hintpath" "$murl" apply || true + local rc=0 + reconcile_bundle_deps "$pkg" "$hintpath" "$murl" report || rc=$? + # rc==2 means the report found changes to apply; anything else (0, or a + # real error) means nothing to prompt about. + if [[ $rc -eq 2 ]]; then + local ans + read -r -p "Apply bundled-dep updates for $pkg? [Y/n] " ans + ans="${ans:-Y}" + if [[ "$ans" =~ ^[Yy]$ ]]; then + reconcile_bundle_deps "$pkg" "$hintpath" "$murl" apply || true + fi fi done } @@ -1516,12 +1527,15 @@ main() { local _bm_url; _bm_url=$(manifest_url_for "$_bm_pkg" "$_bm_cur") echo "" echo "Bundled-dep reconcile: $_bm_pkg (manifest @ $_bm_cur)" - reconcile_bundle_deps "$_bm_pkg" "$_bm_hint" "$_bm_url" report || true - local _bm_ans - read -r -p "Apply bundled-dep updates for $_bm_pkg? [Y/n] " _bm_ans - _bm_ans="${_bm_ans:-Y}" - if [[ "$_bm_ans" =~ ^[Yy]$ ]]; then - reconcile_bundle_deps "$_bm_pkg" "$_bm_hint" "$_bm_url" apply || true + local _bm_rc=0 + reconcile_bundle_deps "$_bm_pkg" "$_bm_hint" "$_bm_url" report || _bm_rc=$? + if [[ $_bm_rc -eq 2 ]]; then + local _bm_ans + read -r -p "Apply bundled-dep updates for $_bm_pkg? [Y/n] " _bm_ans + _bm_ans="${_bm_ans:-Y}" + if [[ "$_bm_ans" =~ ^[Yy]$ ]]; then + reconcile_bundle_deps "$_bm_pkg" "$_bm_hint" "$_bm_url" apply || true + fi fi fi -- cgit v1.2.3