Blob Blame History Raw
From 6eb95429bb92cab5616feaef0111733f79164811 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan=20Pokorn=C3=BD?= <jpokorny@redhat.com>
Date: Thu, 19 Jul 2018 19:11:36 +0200
Subject: [PATCH 3/3] maint: ocf + script: eliminate some false positives with
 ShellCheck
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

In particular, prevent sed's character classes to be confused with
array-like variable access through specified index, which demonstrates
why it's better to have the ${variable} "enbraced".

Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
---
 script/ocf/booth-site      | 7 +++++++
 script/ocf/geostore        | 2 ++
 script/ocf/sharedrsc       | 5 +++++
 script/service-runnable.in | 2 +-
 4 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/script/ocf/booth-site b/script/ocf/booth-site
index 809928c..8178e35 100755
--- a/script/ocf/booth-site
+++ b/script/ocf/booth-site
@@ -30,6 +30,7 @@ DEFAULT_BIN="boothd"
 DEFAULT_CONF="/etc/booth/booth.conf"
 
 : ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
+# shellcheck source=/usr/lib/ocf/lib/heartbeat/ocf-shellfuncs
 . ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
 
 #######################################################################
@@ -140,6 +141,8 @@ booth_site_start() {
 	$OCF_NOT_RUNNING) ;;
 	esac
 
+	# shellcheck disable=SC2154
+	# (OCF_RESKEY_args: injected by CRM)
 	$OCF_RESKEY_daemon daemon -c $OCF_RESKEY_config $OCF_RESKEY_args ||
 		return $OCF_ERR_GENERIC
 	sleep 1
@@ -188,6 +191,8 @@ booth_site_validate_all() {
 		return $OCF_ERR_INSTALLED
 	fi
 
+	# shellcheck disable=SC2154
+	# (OCF_RESKEY_CRM_meta_globally_unique: injected by CRM)
 	if ocf_is_true $OCF_RESKEY_CRM_meta_globally_unique; then
 		ocf_log err "$OCF_RESOURCE_INSTANCE must be configured with the globally_unique=false meta attribute"
 		return $OCF_ERR_CONFIGURED
@@ -198,6 +203,8 @@ booth_site_validate_all() {
 
 : ${OCF_RESKEY_daemon:=$DEFAULT_BIN}
 : ${OCF_RESKEY_config:=$DEFAULT_CONF}
+# shellcheck disable=SC2034
+# (OCF_REQUIRED_BINARIES consumed by ocf_rarun)
 OCF_REQUIRED_BINARIES=${OCF_RESKEY_daemon}
 
 ocf_rarun $*
diff --git a/script/ocf/geostore b/script/ocf/geostore
index 85842a8..c180418 100755
--- a/script/ocf/geostore
+++ b/script/ocf/geostore
@@ -31,7 +31,9 @@
 # Initialization:
 
 : ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
+# shellcheck source=/usr/lib/ocf/lib/heartbeat/ocf-shellfuncs
 . ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
+# shellcheck source=script/ocf/geo_attr.sh
 . ${OCF_ROOT}/lib/booth/geo_attr.sh
 
 #######################################################################
diff --git a/script/ocf/sharedrsc b/script/ocf/sharedrsc
index 384cfd2..c2ed8ff 100755
--- a/script/ocf/sharedrsc
+++ b/script/ocf/sharedrsc
@@ -36,6 +36,7 @@
 # Initialization:
 
 : ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
+# shellcheck source=/usr/lib/ocf/lib/heartbeat/ocf-shellfuncs
 . ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
 
 #######################################################################
@@ -148,6 +149,8 @@ sharedrsc_start() {
 	if ! owner=`runcmd getowner $DIR`; then
 		owner="... nobody, it's only half-claimed"
 	fi
+	# shellcheck disable=SC2154
+	# (OCF_RESKEY_dir: injected by CRM)
 	ocf_log err "eek, $OCF_RESKEY_dir already owned by $owner"
 	return $OCF_ERR_GENERIC
 }
@@ -180,6 +183,8 @@ sharedrsc_validate_all() {
 	return $OCF_SUCCESS
 }
 
+# shellcheck disable=SC2034
+# (OCF_REQUIRED_PARAMS consumed by ocf_rarun)
 OCF_REQUIRED_PARAMS="dir"
 ocf_rarun $*
 
diff --git a/script/service-runnable.in b/script/service-runnable.in
index 9ea33d4..2f58641 100755
--- a/script/service-runnable.in
+++ b/script/service-runnable.in
@@ -30,7 +30,7 @@ fi
 
 if echo "$status" |
 	sed -n '/^Revised cluster status:/,$p' |
-	egrep "^[[:space:]]+$service[[:space:]]+\(.*\):[[:space:]]+Started ([^[:space:]]+) *$" >/dev/null
+	egrep "^[[:space:]]+${service}[[:space:]]+\(.*\):[[:space:]]+Started ([^[:space:]]+) *$" >/dev/null
 then
 	# can be started - we're done.
 	exit 0
-- 
2.18.0.rc2