Plugin pacman_pending_updates: handle absence of available updates properly

"checkupdates" returns the exit code 2, if no updates are pending.
Previously the plugin did not output anything in this case.

Closes: #1233
This commit is contained in:
Lars Kruse 2021-08-08 15:50:54 +02:00
parent 13b9078f76
commit c2aa56531c
1 changed files with 10 additions and 3 deletions

View File

@ -58,14 +58,21 @@ EOM
;;
*)
if updates="$(checkupdates)"; then
updates="$(checkupdates)"
exitcode=$?
if [ "$exitcode" = 0 ]; then
if [ -n "$updates" ]; then
echo "updates.value $(echo "$updates" | wc -l)"
echo "updates.extinfo $(echo "$updates" | paste -s -d,)"
else
echo updates.value 0
echo "updates.value 0"
fi
echo "updates.value U" && exit
elif [ "$exitcode" = 2 ]; then
# Surprisingly "checkupdates" returns the exitcode 2, if all packages are
# up to date.
echo "updates.value 0"
else
echo "updates.value U"
fi
;;
esac