From 3e8814205af0edacbd61a168440c61e54addb057 Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Mon, 8 Nov 2021 11:05:29 +0100 Subject: [PATCH] TT#82051 Shellcheck v0.8 fixes shellcheck v0.8 has new check, known as SC2295 ("Warn about "${x#$y}" treating $y as a pattern when not quoted"). Fixes: | In scripts/build line 117: | build_file="${build_file%%.${host}}" | ^-----^ SC2295 (info): Expansions inside ${..} need to be quoted separately, otherwise they match as patterns. | In scripts/encrypt line 24: | x=${file##${NGCPCTL_MAIN}/templates/} # drop leading /etc/ngcp-config | ^-------------^ SC2295 (info): Expansions inside ${..} need to be quoted separately, otherwise they match as patterns. ... as reported by our Github actions at https://github.com/sipwise/ngcpcfg Change-Id: I3371388ecf445905cca0bc4681276151aceb43ae --- scripts/build | 2 +- scripts/encrypt | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/build b/scripts/build index 73d79645..696ce510 100755 --- a/scripts/build +++ b/scripts/build @@ -114,7 +114,7 @@ else # drop HA file suffix of all registered nodes if [ -r /etc/ngcp-config/systems.cfg ] ; then while IFS= read -r host ; do - build_file="${build_file%%.${host}}" + build_file="${build_file%%."${host}"}" done < /etc/ngcp-config/systems.cfg fi diff --git a/scripts/encrypt b/scripts/encrypt index 8c15f9c2..920030a8 100755 --- a/scripts/encrypt +++ b/scripts/encrypt @@ -21,12 +21,12 @@ get_config_file_list() { for dir in ${CONFIG_POOL} ; do # shellcheck disable=SC2044 for file in $(find "${TEMPLATE_POOL_BASE}/${dir}" -name \*.tt2 -o -name \*.tt2"${HA_FILE:-}") ; do - x=${file##${NGCPCTL_MAIN}/templates/} # drop leading /etc/ngcp-config - y=${x%%.tt2} # drop trailing suffix '.tt2' - y=${y%%.tt2.sp1} # drop trailing suffix '.tt2.sp1' - y=${y%%.tt2.sp2} # drop trailing suffix '.tt2.sp2' - y=${y%%.customtt} # drop trailing suffix '.customtt' - y=${y%%.patchtt} # drop trailing suffix '.patchtt' + x=${file##"${NGCPCTL_MAIN}"/templates/} # drop leading /etc/ngcp-config + y=${x%%.tt2} # drop trailing suffix '.tt2' + y=${y%%.tt2.sp1} # drop trailing suffix '.tt2.sp1' + y=${y%%.tt2.sp2} # drop trailing suffix '.tt2.sp2' + y=${y%%.customtt} # drop trailing suffix '.customtt' + y=${y%%.patchtt} # drop trailing suffix '.patchtt' # if the file does not exist (e.g. because "ngcpcfg apply" # hasn't been executed yet for whatever reason, then don't # report missing files, otherwise tar will complain