summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2017-05-25 14:39:05 -0400
committerLuke Shumaker <lukeshu@lukeshu.com>2017-05-25 17:28:30 -0400
commit6092b9d93df1c3d5170a2b6aa0275aebef18bd37 (patch)
tree55627e026fa7f538f8085f0fb8ed1fffcce4fcbc /src/lib
parentaedbebb0ea3c7b40dda987b43ff21475ef67f423 (diff)
start moving things to use the libremessages exit codes
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/blacklist.sh2
-rw-r--r--src/lib/conf.sh.in12
-rwxr-xr-xsrc/lib/libreblacklist4
-rw-r--r--src/lib/messages.sh2
4 files changed, 10 insertions, 10 deletions
diff --git a/src/lib/blacklist.sh b/src/lib/blacklist.sh
index fc07815..249ee89 100644
--- a/src/lib/blacklist.sh
+++ b/src/lib/blacklist.sh
@@ -61,7 +61,7 @@ blacklist-update() (
_l warning "Using local copy of blacklist"
else
_l error "Download failed, exiting"
- return 1
+ return 1 # $EXIT_FAILURE
fi
fi
diff --git a/src/lib/conf.sh.in b/src/lib/conf.sh.in
index 7d1646b..f2d515d 100644
--- a/src/lib/conf.sh.in
+++ b/src/lib/conf.sh.in
@@ -109,7 +109,7 @@ list_envvars() {
# Loads the configuration files for $slug in the proper order, and
# optionally verify that certain variables are set.
load_conf() {
- [[ "$1" = *.conf ]] || libremessages panic || exit 1
+ [[ "$1" = *.conf ]] || libremessages panic || exit 1 # $EXIT_FAILURE
local slug=${1%.conf}
shift
@@ -123,7 +123,7 @@ load_conf() {
# Load the files
while read -r file; do
if [[ -r $file ]]; then
- . "$file" || return 6
+ . "$file" || return 6 # $EXIT_NOTCONFIGURED
fi
done < <(list_files "$slug")
@@ -133,7 +133,7 @@ load_conf() {
done < <(list_envvars "$slug")
# Verify that the variables we need were set
- declare -i ret=0
+ declare -i ret=0 # $EXIT_SUCCESS
for var in "$@"; do
if [[ -z ${!var:-} ]]; then
if [[ $(list_files "$slug"|wc -l) -gt 1 ]]; then
@@ -142,7 +142,7 @@ load_conf() {
else
libremessages _l print "Configure '%s' in '%s'" "$var" "$(list_files "$slug")"
fi
- ret=6
+ ret=6 # $EXIT_NOTCONFIGURED
fi
done >&2
return $ret
@@ -170,10 +170,10 @@ set_var() {
if [[ -w $file ]]; then
sed -i "/^\s*$key=/d" "$file"
printf '%s=%q\n' "$key" "$val" >> "$file"
- return 0
+ return 0 # $EXIT_SUCCESS
fi
done < <(list_files "$slug"|tac)
- return 1
+ return 1 # $EXIT_FAILURE
}
# PKGBUILD (not configuration, per se) #########################################
diff --git a/src/lib/libreblacklist b/src/lib/libreblacklist
index 6c354fe..d6fc7f3 100755
--- a/src/lib/libreblacklist
+++ b/src/lib/libreblacklist
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
-# Copyright (C) 2013-2014, 2016 Luke Shumaker <lukeshu@sbcglobal.net>
+# Copyright (C) 2013-2014, 2016-2017 Luke Shumaker <lukeshu@sbcglobal.net>
#
# License: GNU GPLv2+
#
@@ -68,7 +68,7 @@ else
main() {
if [[ $# -eq 0 ]]; then
usage >&2
- exit 1
+ exit $EXIT_INVALIDARGUMENT
fi
_blacklist_cmd=$1
shift
diff --git a/src/lib/messages.sh b/src/lib/messages.sh
index d989469..37ee1b8 100644
--- a/src/lib/messages.sh
+++ b/src/lib/messages.sh
@@ -58,7 +58,7 @@ declare -rgi EXIT_NOTCONFIGURED=6
# For programming errors, bails immediately with little fanfare.
panic() {
_l _ 'panic: malformed call to internal function' >&2
- exit 1
+ exit $EXIT_FAILURE
}
# Usage: print MESG [ARGS...]