summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortv <tv@shackspace.de>2014-08-11 22:01:41 +0200
committertv <tv@shackspace.de>2014-08-11 22:01:41 +0200
commit2bcb24199008ae2852af9a62e12959da5f67411b (patch)
tree618e4c6ed302de44f03b2fb6e39e0233fd9ee5b2
parentb62400bcfa8f5551ea8c3ef7c5f2aecf008bd7f0 (diff)
Reaktor nag: dry up output function with eval^_^
-rwxr-xr-xReaktor/commands/nag34
1 files changed, 18 insertions, 16 deletions
diff --git a/Reaktor/commands/nag b/Reaktor/commands/nag
index fabeec8d..8962d9fb 100755
--- a/Reaktor/commands/nag
+++ b/Reaktor/commands/nag
@@ -40,26 +40,28 @@ if test "${inspect_services-false}" = true; then
missing_mailtos=$(set +f; cd nag.services && grep '^mailto:$' * | cut -d: -f1)
fi
+nag_missing_services='missing services'
+nag_obsolete_services='obsolete services'
+nag_missing_owners='services with missing owner entry'
+nag_missing_mailtos='services with missing mailto entry'
+
#
# output
#
did_nag=false
-if test -n "$missing_services"; then
- echo missing services: $missing_services
- did_nag=true
-fi
-if test -n "$obsolete_services"; then
- echo obsolete services: $obsolete_services
- did_nag=true
-fi
-if test -n "${missing_owners-}"; then
- echo services with missing owner entry: $missing_owners
- did_nag=true
-fi
-if test -n "${missing_mailtos-}"; then
- echo services with missing mailto entry: $missing_mailtos
- did_nag=true
-fi
+for i in \
+ missing_services \
+ obsolete_services \
+ missing_owners \
+ missing_mailtos
+do
+ eval "offenders=\$$i; nag_msg=\$nag_$i"
+ if test -n "$offenders"; then
+ echo $nag_msg: $offenders
+ did_nag=true
+ fi
+done
+
# if asked directly, answer if there is nothing to nag about
if test $did_nag = false -a -n "${_from:-}";then
echo "nothing to nag about"