[4/4] checkupdates: exit 2 if no updates are available

Message ID 20191023061359.820902-4-eschwartz@archlinux.org
State Accepted
Headers show
Series
  • [1/4] Port to libmakepkg
Related show

Commit Message

Eli Schwartz Oct. 23, 2019, 6:13 a.m. UTC
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@archlinux.org>
---
 doc/checkupdates.8.txt | 14 ++++++++++++++
 src/checkupdates.sh.in |  2 +-
 2 files changed, 15 insertions(+), 1 deletion(-)

Patch

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: