From: Daniel Farrell Date: Wed, 14 Nov 2018 14:20:10 +0000 (+0000) Subject: Fix SC2059 for ShellCheck 0.4.4, printf formatting X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=45589cf60e5c450945cbb3f5bf8426b13b9b2a28;hp=--cc;p=releng%2Fbuilder.git Fix SC2059 for ShellCheck 0.4.4, printf formatting Consistently with shellcheck 0.4.4, but tested-not 0.4.5, 0.4.6 or 0.5.0, linting fails on inserting strings directly into printf first arguments vs passing as secondary arguments. The reasoning is related to vars with special chars being executed vs treated literally. The default version of shellcheck in still-supported OS distro package repos (for example Debian 9.6) is 0.4.4. The packer baseline script installs shellcheck 0.4.6 manually. Shellcheck 0.5.0 is the current latest. Change-Id: I202611873b7bd09c65061e29eb2d1bfbdb2085c1 Signed-off-by: Daniel Farrell --- 45589cf60e5c450945cbb3f5bf8426b13b9b2a28 diff --git a/jjb/integration/common-functions.sh b/jjb/integration/common-functions.sh index 53ed46ada..ced2cc36e 100644 --- a/jjb/integration/common-functions.sh +++ b/jjb/integration/common-functions.sh @@ -145,7 +145,7 @@ function run_plan() { ;; esac - printf "Locating ${type} plan to use...\n" + printf "Locating %s plan to use...\n" "${type}" plan_filepath="${WORKSPACE}/test/csit/${type}plans/$plan" if [ ! -f "${plan_filepath}" ]; then plan_filepath="${WORKSPACE}/test/csit/${type}plans/${STREAMTESTPLAN}" @@ -155,17 +155,17 @@ function run_plan() { fi if [ -f "${plan_filepath}" ]; then - printf "${type} plan exists!!!\n" - printf "Changing the ${type} plan path...\n" + printf "%s plan exists!!!\n" "${type}" + printf "Changing the %s plan path...\n" "${type}" cat ${plan_filepath} | sed "s:integration:${WORKSPACE}:" > ${type}plan.txt cat ${type}plan.txt for line in $( egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' ${type}plan.txt ); do - printf "Executing ${line}...\n" + printf "Executing %s...\n" "${line}" # shellcheck source=${line} disable=SC1091 source ${line} done fi - printf "Finished running ${type} plans\n" + printf "Finished running %s plans\n" "${type}" } # function run_plan() # Return elapsed time. Usage: @@ -175,7 +175,7 @@ function timer() { if [ $# -eq 0 ]; then # return the current time - printf "$(date "+%s")" + printf "%s" "$(date "+%s")" else local start_time=$1 end_time=$(date "+%s") @@ -268,7 +268,7 @@ function tcpdump_start() { local -r filter=$3 filter_=${filter// /_} - printf "node ${ip}, ${prefix}_${ip}__${filter}: starting tcpdump\n" + printf "node %s, %s_%s__%s: starting tcpdump\n" "${ip}" "${prefix}" "${ip}" "${filter}" ssh ${ip} "nohup sudo /usr/sbin/tcpdump -vvv -ni eth0 ${filter} -w /tmp/tcpdump_${prefix}_${ip}__${filter_}.pcap > /tmp/tcpdump_start.log 2>&1 &" ${SSH} ${ip} "ps -ef | grep tcpdump" } @@ -276,7 +276,7 @@ function tcpdump_start() { function tcpdump_stop() { local -r ip=$1 - printf "node $ip: stopping tcpdump\n" + printf "node %s: stopping tcpdump\n" "$ip" ${SSH} ${ip} "ps -ef | grep tcpdump.sh" ${SSH} ${ip} "sudo pkill -f tcpdump" ${SSH} ${ip} "sudo xz -9ekvvf /tmp/*.pcap" @@ -332,7 +332,7 @@ function collect_openstack_logs() { local -r node_type=${3} local oslogs="${folder}/oslogs" - printf "collect_openstack_logs for ${node_type} node: ${ip} into ${oslogs}\n" + printf "collect_openstack_logs for %s node: %s into %s\n" "${node_type}" "${ip}" "${oslogs}" rm -rf ${oslogs} mkdir -p ${oslogs} # There are always some logs in /opt/stack/logs and this also covers the @@ -372,7 +372,7 @@ fi ls -al /tmp/oslogs EOF # cat > ${WORKSPACE}/collect_openstack_logs.sh << EOF - printf "collect_openstack_logs for ${node_type} node: ${ip} into ${oslogs}, executing script\n" + printf "collect_openstack_logs for %s node: %s into %s, executing script\n" "${node_type}" "${ip}" "${oslogs}" cat ${WORKSPACE}/collect_openstack_logs.sh scp ${WORKSPACE}/collect_openstack_logs.sh ${ip}:/tmp ${SSH} ${ip} "bash /tmp/collect_openstack_logs.sh > /tmp/collect_openstack_logs.log 2>&1" diff --git a/jjb/integration/integration-deploy-openstack-run-test.sh b/jjb/integration/integration-deploy-openstack-run-test.sh index 95c26c47c..6c6ecbd69 100644 --- a/jjb/integration/integration-deploy-openstack-run-test.sh +++ b/jjb/integration/integration-deploy-openstack-run-test.sh @@ -123,7 +123,7 @@ function install_rdo_release() { # Involves just setting up the shared directory function setup_live_migration_control() { local control_ip=$1 - printf "${control_ip}:Setup directory Share with NFS" + printf "%s:Setup directory Share with NFS" "${control_ip}" cat > ${WORKSPACE}/setup_live_migration_control.sh << EOF sudo mkdir --mode=777 /vm_instances sudo chown -R jenkins:jenkins /vm_instances @@ -140,8 +140,8 @@ EOF function setup_live_migration_compute() { local compute_ip=$1 local control_ip=$2 - printf "${compute_ip}:Mount Shared directory from ${control_ip}" - printf "${compute_ip}:Configure libvirt in listen mode" + printf "%s:Mount Shared directory from ${control_ip}" "${compute_ip}" + printf "%s:Configure libvirt in listen mode" "${compute_ip}" cat > ${WORKSPACE}/setup_live_migration_compute.sh << EOF sudo yum install -y libvirt libvirt-devel nfs-utils sudo crudini --verbose --set --inplace /etc/libvirt/libvirtd.conf '' listen_tls 0