Misc code quality improvements to find-pid
@@ -76,23 +76,23 @@ findhost
set -euo pipefail
-if [ $# -ne 1 ]; then
+if (( $# != 1 )); then
echo "Usage: $0 <service-config-id>" >&2
exit 1
fi
-readonly service=$1
-readonly status=$(vespa-sentinel-cmd list 2>/dev/null | grep "id=\"${service}\"")
+readonly config_id=$1
+readonly status=$(vespa-sentinel-cmd list 2>/dev/null | grep "id=\"${config_id}\"")
if [ -z "${status}" ]; then
- echo "No service named '${service}'" >&2
+ echo "No service named '${config_id}'" >&2
exit 1
fi
readonly pid=$(echo ${status} | cut -d " " -f 4 | cut -d "=" -f 2)
if ! [[ "${pid}" =~ ^[0-9]+$ ]]; then
- echo "Could not find valid pid for '${service}' (pid='${pid}')" >&2
+ echo "Could not find valid pid for '${config_id}' (pid='${pid}')" >&2
exit 1
fi
-if ! [ -n $(ps -p ${pid} -o pid=) ]; then
+if [ -z "$(ps -p ${pid} -o pid=)" ]; then
echo "Could not find process for '${pid}'" >&2
exit 1
fi
