fix: robust AUR update detection in updateall

- replace fragile quoted test -z "$aur_qu" with count-based empty check for fish list handling
- separate success (code 0 + empty) vs error (code !=0 + empty) to avoid false up-to-date on network failures
- use string match -qr with explicit patterns for helpers messages instead of quoted glob checks
- fix global leak: use set -l answer and read -l, validate with string match -qr ^[Yy]$
- deduplicate and clarify error vs pending branches while keeping mandatory PKGBUILD review guard
This commit is contained in:
Your Name
2026-08-25 14:29:10 +00:00
parent e12d3d42cb
commit 444ca8c57d
+35 -12
View File
@@ -230,22 +230,47 @@ function updateall
if test -n "$aur_helper" if test -n "$aur_helper"
set -l aur_qu ($aur_helper -Qua 2>&1) set -l aur_qu ($aur_helper -Qua 2>&1)
set -l aur_qu_code $status set -l aur_qu_code $status
if test $aur_qu_code -ne 0; or test -z "$aur_qu"
if string match -q "*there is nothing to do*" "$aur_qu"; or string match -q "*No AUR*" "$aur_qu"; or test -z "$aur_qu" # Robust state detection: use (count) not quoted -z, and explicit patterns.
# aur_qu is a list (one element per line) -> count is reliable.
set -l aur_is_up_to_date 0
set -l aur_has_check_error 0
if test $aur_qu_code -eq 0
if test (count $aur_qu) -eq 0
set aur_is_up_to_date 1
else if string match -qr -- "there is nothing to do|No AUR|No packages to upgrade" $aur_qu
set aur_is_up_to_date 1
end
else
# Non-zero: only treat as up-to-date if helper explicitly says so
if string match -qr -- "there is nothing to do|No AUR" $aur_qu
set aur_is_up_to_date 1
else
set aur_has_check_error 1
end
end
if test $aur_is_up_to_date -eq 1
echo "AUR: up to date" echo "AUR: up to date"
set aur_status "up to date" set aur_status "up to date"
set aur_color green set aur_color green
else if test $aur_has_check_error -eq 1
# Real check failure: do NOT silently report up-to-date
echo "Failed to check for AUR updates (code $aur_qu_code):"
if test (count $aur_qu) -gt 0
printf "%s\n" $aur_qu
else else
# Fallback: assume updates, but still enforce review echo "(no output)"
echo "Failed to check for AUR updates:" end
echo "" echo ""
set_color yellow set_color yellow
echo "==> AUR PKGBUILD review is MANDATORY - diff cannot be skipped." echo "==> AUR PKGBUILD review is MANDATORY - diff cannot be skipped."
echo " Note: PKGBUILDs must NEVER contain 'sudo'. Please verify diffs contain no 'sudo'." echo " Note: PKGBUILDs must NEVER contain 'sudo'. Please verify diffs contain no 'sudo'."
set_color normal set_color normal
set answer "" set -l answer ""
read -P "Update now? [y/N]: " answer read -l -P "Update now? [y/N]: " answer
if test "$answer" = "y" -o "$answer" = "Y" if string match -qr -- "^[Yy]\$" "$answer"
if test "$aur_helper" = "paru" if test "$aur_helper" = "paru"
paru -Sua --sudoloop --review paru -Sua --sudoloop --review
else else
@@ -260,7 +285,6 @@ function updateall
set aur_color red set aur_color red
end end
end end
end
else else
echo "Pending AUR updates:" echo "Pending AUR updates:"
printf "%s\n" $aur_qu printf "%s\n" $aur_qu
@@ -268,9 +292,9 @@ function updateall
echo "==> AUR PKGBUILD review is MANDATORY - diff cannot be skipped." echo "==> AUR PKGBUILD review is MANDATORY - diff cannot be skipped."
echo " Note: PKGBUILDs must NEVER contain 'sudo'. Please verify diffs contain no 'sudo'." echo " Note: PKGBUILDs must NEVER contain 'sudo'. Please verify diffs contain no 'sudo'."
set_color normal set_color normal
set answer "" set -l answer ""
read -P "Update now? [y/N]: " answer read -l -P "Update now? [y/N]: " answer
if test "$answer" = "y" -o "$answer" = "Y" if string match -qr -- "^[Yy]\$" "$answer"
if test "$aur_helper" = "paru" if test "$aur_helper" = "paru"
paru -Sua --sudoloop --review paru -Sua --sudoloop --review
else else
@@ -285,7 +309,6 @@ function updateall
set aur_color red set aur_color red
end end
end end
end end
else else
echo "No AUR helper (paru/yay) found, skipping" echo "No AUR helper (paru/yay) found, skipping"