summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2017-05-25 16:14:49 -0400
committerLuke Shumaker <lukeshu@lukeshu.com>2017-05-25 16:55:03 -0400
commitaedbebb0ea3c7b40dda987b43ff21475ef67f423 (patch)
treec4b69c21902ca5e4ecba3227014c53abe172ff4d
parent01d4cfea634d1c1c5f0ab3c040ce12b39c165054 (diff)
messages: define EXIT_* codes
-rw-r--r--src/lib/libremessages.1.ronn10
-rw-r--r--src/lib/messages.sh16
2 files changed, 25 insertions, 1 deletions
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) <hahj87@gmail.com>
# Copyright (C) 2012 Nicolás Reynolds <fauno@parabola.nu>
-# Copyright (C) 2012-2014, 2016 Luke Shumaker <lukeshu@sbcglobal.net>
+# Copyright (C) 2012-2014, 2016-2017 Luke Shumaker <lukeshu@sbcglobal.net>
#
# For just the setup_traps() function:
# Copyright (C) 2002-2006 Judd Vinet <jvinet@zeroflux.org>
@@ -29,6 +29,9 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+[[ -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.