aboutsummaryrefslogtreecommitdiff
path: root/lib/util.bash
diff options
context:
space:
mode:
authorPatrick Spek <p.spek@tyil.nl>2022-04-17 22:56:59 +0200
committerPatrick Spek <p.spek@tyil.nl>2022-04-17 22:56:59 +0200
commitfba67928920f3b1e6d10123de9a7efae0dac177f (patch)
tree1b94866fde92c24c660f181fd1631f380595b349 /lib/util.bash
parentfa150b95d3d9d9b3ea51a03e9243d2b4b2a6c761 (diff)
Make shellcheck happy
Diffstat (limited to 'lib/util.bash')
-rw-r--r--lib/util.bash30
1 files changed, 21 insertions, 9 deletions
diff --git a/lib/util.bash b/lib/util.bash
index ea9ac3b..79bac92 100644
--- a/lib/util.bash
+++ b/lib/util.bash
@@ -32,7 +32,7 @@ config_for() {
"$BASHTARD_ETCDIR/defaults"
)
- if [[ ! -z "$BASHTARD_PLAYBOOK" ]]
+ if [[ -n "$BASHTARD_PLAYBOOK" ]]
then
debug "bashtard/config_for" "BASHTARD_PLAYBOOK=$BASHTARD_PLAYBOOK, adding etc entries"
files+=(
@@ -189,9 +189,10 @@ join_args() {
# OS independent package management
pkg() {
local system="bashtard/pkg"
-
local action=$1 ; shift
- local pkg="$(config "pkg.$1")" ; shift
+ local pkg
+
+ pkg="$(config "pkg.$1")" ; shift
if [[ -z $pkg ]]
then
@@ -199,7 +200,7 @@ pkg() {
return 1
fi
- if [[ "$(type -t pkg_$action)" != "function" ]]
+ if [[ "$(type -t "pkg_$action")" != "function" ]]
then
crit "$system" "Invalid package manager action $action"
return 1
@@ -224,6 +225,7 @@ pkg_install() {
esac
notice "$system" "$*"
+ # shellcheck disable=SC2068
$@
}
@@ -243,6 +245,7 @@ pkg_uninstall() {
esac
notice "$system" "$*"
+ # shellcheck disable=SC2068
$@
}
@@ -254,7 +257,7 @@ svc() {
local action
action=$1 ; shift
- service="$(config svc.$1)" ; shift
+ service="$(config "svc.$1")" ; shift
if [[ -z $service ]]
then
@@ -262,7 +265,7 @@ svc() {
return 1
fi
- if [[ "$(type -t svc_$action)" != "function" ]]
+ if [[ "$(type -t "svc_$action")" != "function" ]]
then
crit "$system" "Invalid service manager action $action"
return 1
@@ -285,6 +288,7 @@ svc_disable() {
esac
notice "$system" "$*"
+ # shellcheck disable=SC2068
$@
}
@@ -302,6 +306,7 @@ svc_enable() {
esac
notice "$system" "$*"
+ # shellcheck disable=SC2068
$@
}
@@ -320,6 +325,7 @@ svc_reload() {
esac
notice "$system" "$*"
+ # shellcheck disable=SC2068
$@
}
@@ -338,6 +344,7 @@ svc_restart() {
esac
notice "$system" "$*"
+ # shellcheck disable=SC2068
$@
}
@@ -356,6 +363,7 @@ svc_start() {
esac
notice "$system" "$*"
+ # shellcheck disable=SC2068
$@
}
@@ -374,13 +382,16 @@ svc_stop() {
esac
notice "$system" "$*"
+ # shellcheck disable=SC2068
$@
}
file_template()
{
local file="$BASHTARD_ETCDIR/playbooks.d/$BASHTARD_PLAYBOOK/share/$1" ; shift
- local sedfile="$(tmpfile)"
+ local sedfile
+
+ sedfile="$(tmpfile)"
if [[ ! -f $file ]]
then
@@ -392,20 +403,21 @@ file_template()
do
debug "bashtard/template" "Adding $kv to sedfile at $sedfile"
- key="$(awk -F= '{ print $1 }' <<< $kv)"
+ key="$(awk -F= '{ print $1 }' <<< "$kv")"
if [[ -z "$key" ]]
then
crit "bashtard/template" "Empty key in '$kv' while rendering $file?"
fi
- value="$(awk -F= '{ print $NF }' <<< $kv)"
+ value="$(awk -F= '{ print $NF }' <<< "$kv")"
if [[ -z "$value" ]]
then
crit "bashtard/template" "Empty key in '$kv' while rendering $file?"
fi
+ # shellcheck disable=SC2016
printf 's@${%s}@%s@g\n' "$key" "$value" >> "$sedfile"
done