From aedbebb0ea3c7b40dda987b43ff21475ef67f423 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Thu, 25 May 2017 16:14:49 -0400 Subject: messages: define EXIT_* codes --- src/lib/libremessages.1.ronn | 10 ++++++++++ src/lib/messages.sh | 16 +++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/lib/libremessages.1.ronn b/src/lib/libremessages.1.ronn index 23e0e18..538a9b4 100644 --- a/src/lib/libremessages.1.ronn +++ b/src/lib/libremessages.1.ronn @@ -38,6 +38,16 @@ error is not a terminal (see `isatty`(3)), they are set, but empty. They are marked as readonly, so it is an error to try to set them afterwards. +The following variables for numeric exit codes are set: a basic +`EXIT_TRUE=0` and `EXIT_FALSE=1`, and well as several based on +the [LSB recommendations for SysV init scripts][1]: `EXIT_SUCCESS`, +`EXIT FAILURE`, `EXIT_INVALIDARGUMENT`, `EXIT_NOTIMPLEMENTED`, +`EXIT_NOPERMISSION`, `EXIT_NOTINSTALLED`, and `EXIT_NOTCONFIGURED`. +They are marked as readonly, so it is an error to try to set them +afterwards. + +[1]: http://refspecs.linuxbase.org/LSB_3.1.1/LSB-Core-generic/LSB-Core-generic/iniscrptact.html + ### MESSAGE FORMAT All routines feed the message/format string through `gettext`(1), if diff --git a/src/lib/messages.sh b/src/lib/messages.sh index 6d7dbfd..d989469 100644 --- a/src/lib/messages.sh +++ b/src/lib/messages.sh @@ -3,7 +3,7 @@ # Copyright (C) 2011 Joshua Ismael Haase Hernández (xihh) # Copyright (C) 2012 Nicolás Reynolds -# Copyright (C) 2012-2014, 2016 Luke Shumaker +# Copyright (C) 2012-2014, 2016-2017 Luke Shumaker # # For just the setup_traps() function: # Copyright (C) 2002-2006 Judd Vinet @@ -29,6 +29,9 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +[[ -z ${_INCLUDE_MESSAGES_SH:-} ]] || return 0 +_INCLUDE_MESSAGES_SH=true + ################################################################################ # Inherit most functions from devtools # ################################################################################ @@ -39,6 +42,17 @@ # Own functions # ################################################################################ +declare -rgi EXIT_TRUE=0 +declare -rgi EXIT_FALSE=1 + +declare -rgi EXIT_SUCCESS=0 +declare -rgi EXIT_FAILURE=1 # generic/unspecified error +declare -rgi EXIT_INVALIDARGUMENT=2 +declare -rgi EXIT_NOTIMPLEMENTED=3 +declare -rgi EXIT_NOPERMISSION=4 +declare -rgi EXIT_NOTINSTALLED=5 +declare -rgi EXIT_NOTCONFIGURED=6 + # Usage: panic # # For programming errors, bails immediately with little fanfare. -- cgit v1.2.2