[pacman-contrib] [PATCH 4/4] checkupdates: exit 2 if no updates are available

Eli Schwartz eschwartz at archlinux.org
Wed Oct 23 06:13:59 UTC 2019


It's useful to distinguish the failure to find updates. This carries
over the ability for pacman -Qu to return errors when no upgrades are
available.

At the same time, this should (unlike pacman -Qu) use its own unique
return code, since checkupdates may error for a couple of reasons
including download issues.

Fixes FS#64219

Signed-off-by: Eli Schwartz <eschwartz at archlinux.org>
---
 doc/checkupdates.8.txt | 14 ++++++++++++++
 src/checkupdates.sh.in |  2 +-
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/doc/checkupdates.8.txt b/doc/checkupdates.8.txt
index ff10930..b1a94d8 100644
--- a/doc/checkupdates.8.txt
+++ b/doc/checkupdates.8.txt
@@ -39,6 +39,20 @@ Environment
 	Overrides the default '/tmp' temporary directory.
 
 
+Errors
+------
+On exit, checkpkg will return one of the following error codes.
+
+0::
+	Normal exit condition.
+
+1::
+	Unknown cause of failure.
+
+2::
+	No updates are available.
+
+
 See Also
 --------
 linkman:pacman[8], linkman:pacman.conf[5]
diff --git a/src/checkupdates.sh.in b/src/checkupdates.sh.in
index eecb4a7..52f8899 100644
--- a/src/checkupdates.sh.in
+++ b/src/checkupdates.sh.in
@@ -109,7 +109,7 @@ if (( ${#updates[@]} )); then
 		sudo pacman -Sw --noconfirm "${updates[@]%% *}" --dbpath "$CHECKUPDATES_DB" --logfile /dev/null
 	fi
 else
-	exit 1
+	exit 2
 fi
 
 # vim: set noet:
-- 
2.23.0


More information about the pacman-contrib mailing list