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:
+59
-36
@@ -230,47 +230,71 @@ function updateall
|
||||
if test -n "$aur_helper"
|
||||
set -l aur_qu ($aur_helper -Qua 2>&1)
|
||||
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"
|
||||
echo "AUR: up to date"
|
||||
set aur_status "up to date"
|
||||
set aur_color green
|
||||
else
|
||||
# Fallback: assume updates, but still enforce review
|
||||
echo "Failed to check for AUR updates:"
|
||||
echo ""
|
||||
set_color yellow
|
||||
echo "==> AUR PKGBUILD review is MANDATORY - diff cannot be skipped."
|
||||
echo " Note: PKGBUILDs must NEVER contain 'sudo'. Please verify diffs contain no 'sudo'."
|
||||
set_color normal
|
||||
set answer ""
|
||||
read -P "Update now? [y/N]: " answer
|
||||
if test "$answer" = "y" -o "$answer" = "Y"
|
||||
if test "$aur_helper" = "paru"
|
||||
paru -Sua --sudoloop --review
|
||||
else
|
||||
yay -Sua --sudoloop --diffmenu --answerdiff All --answerclean All
|
||||
end
|
||||
set -l _aur_code $status
|
||||
if test $_aur_code -eq 0
|
||||
set aur_status "updated"
|
||||
set aur_color green
|
||||
else
|
||||
set aur_status "failed ($_aur_code)"
|
||||
set aur_color red
|
||||
end
|
||||
end
|
||||
|
||||
# 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
|
||||
echo "Pending AUR updates:"
|
||||
printf "%s\n" $aur_qu
|
||||
# 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"
|
||||
set aur_status "up to date"
|
||||
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
|
||||
echo "(no output)"
|
||||
end
|
||||
echo ""
|
||||
set_color yellow
|
||||
echo "==> AUR PKGBUILD review is MANDATORY - diff cannot be skipped."
|
||||
echo " Note: PKGBUILDs must NEVER contain 'sudo'. Please verify diffs contain no 'sudo'."
|
||||
set_color normal
|
||||
set answer ""
|
||||
read -P "Update now? [y/N]: " answer
|
||||
if test "$answer" = "y" -o "$answer" = "Y"
|
||||
set -l answer ""
|
||||
read -l -P "Update now? [y/N]: " answer
|
||||
if string match -qr -- "^[Yy]\$" "$answer"
|
||||
if test "$aur_helper" = "paru"
|
||||
paru -Sua --sudoloop --review
|
||||
else
|
||||
yay -Sua --sudoloop --diffmenu --answerdiff All --answerclean All
|
||||
end
|
||||
set -l _aur_code $status
|
||||
if test $_aur_code -eq 0
|
||||
set aur_status "updated"
|
||||
set aur_color green
|
||||
else
|
||||
set aur_status "failed ($_aur_code)"
|
||||
set aur_color red
|
||||
end
|
||||
end
|
||||
else
|
||||
echo "Pending AUR updates:"
|
||||
printf "%s\n" $aur_qu
|
||||
set_color yellow
|
||||
echo "==> AUR PKGBUILD review is MANDATORY - diff cannot be skipped."
|
||||
echo " Note: PKGBUILDs must NEVER contain 'sudo'. Please verify diffs contain no 'sudo'."
|
||||
set_color normal
|
||||
set -l answer ""
|
||||
read -l -P "Update now? [y/N]: " answer
|
||||
if string match -qr -- "^[Yy]\$" "$answer"
|
||||
if test "$aur_helper" = "paru"
|
||||
paru -Sua --sudoloop --review
|
||||
else
|
||||
@@ -285,7 +309,6 @@ function updateall
|
||||
set aur_color red
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
else
|
||||
echo "No AUR helper (paru/yay) found, skipping"
|
||||
|
||||
Reference in New Issue
Block a user