From 6092b9d93df1c3d5170a2b6aa0275aebef18bd37 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Thu, 25 May 2017 14:39:05 -0400 Subject: start moving things to use the libremessages exit codes --- src/lib/blacklist.sh | 2 +- src/lib/conf.sh.in | 12 ++++++------ src/lib/libreblacklist | 4 ++-- src/lib/messages.sh | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) (limited to 'src/lib') 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 +# Copyright (C) 2013-2014, 2016-2017 Luke Shumaker # # 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...] -- cgit v1.2.3-54-g00ecf