From 13701d5b6c5929925033ad8efdd9b8a5e4d27ddd Mon Sep 17 00:00:00 2001 From: Artem Savinov Date: Fri, 15 Apr 2016 13:14:25 +0300 Subject: [PATCH] Fix warnings from code check tools * Fixed shellcheck warnings Change-Id: Iae750a34b9aec24d499ca72524c7c915f8b76695 --- plugin_test/utils/jenkins/system_tests.sh | 12 ++++++------ remove_modules.sh | 8 ++++---- update_modules.sh | 6 +++--- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/plugin_test/utils/jenkins/system_tests.sh b/plugin_test/utils/jenkins/system_tests.sh index 1e81aa5..c7c807a 100755 --- a/plugin_test/utils/jenkins/system_tests.sh +++ b/plugin_test/utils/jenkins/system_tests.sh @@ -410,7 +410,7 @@ MakeISO() { if [ "${DRY_RUN}" = "yes" ]; then ISO="${WORKSPACE}/build/iso/fuel.iso" else - ISO="`ls ${WORKSPACE}/build/iso/*.iso | head -n 1`" + ISO="$(find ${WORKSPACE}/build/iso/ -maxdepth 1 -type f -name '*.iso'|sort -d| head -n 1)" # check that ISO file exists if [ ! -f "${ISO}" ]; then echo "Error! ISO file not found!" @@ -545,7 +545,7 @@ RunTest() { if [ "${DRY_RUN}" = "yes" ]; then echo dos.py erase "${ENV_NAME}" else - if [ "$(dos.py list | grep "^${ENV_NAME}\$")" ]; then + if dos.py list | grep -q "^${ENV_NAME}\$" ; then dos.py erase "${ENV_NAME}" fi fi @@ -584,7 +584,7 @@ RunTest() { exit 1 fi - while [ "$(virsh net-list | grep $ENV_NAME | wc -l)" -ne 5 ];do sleep 10 + while [ "$(virsh net-list | grep -c $ENV_NAME)" -ne 5 ];do sleep 10 if ! ps -p $SYSTEST_PID > /dev/null then echo System tests exited prematurely, aborting @@ -645,7 +645,7 @@ add_interface_to_bridge() { ip=$4 for net in $(virsh net-list |grep ${env}_${net_name} |awk '{print $1}');do - bridge=`virsh net-info $net |grep -i bridge |awk '{print $2}'` + bridge=$(virsh net-info $net |grep -i bridge |awk '{print $2}') setup_bridge $bridge $nic $ip && echo $net_name bridge $bridge ready done } @@ -658,7 +658,7 @@ setup_bridge() { sudo /sbin/brctl stp $bridge off sudo /sbin/brctl addif $bridge $nic # set if with existing ip down - for itf in `sudo ip -o addr show to $ip |cut -d' ' -f2`; do + for itf in $(sudo ip -o addr show to $ip |cut -d' ' -f2); do echo deleting $ip from $itf sudo ip addr del dev $itf $ip done @@ -674,7 +674,7 @@ setup_bridge() { clean_old_bridges() { for intf in $WORKSTATION_IFS; do - for br in `/sbin/brctl show | grep -v "bridge name" | cut -f1 -d' '`; do + for br in $(/sbin/brctl show | grep -v "bridge name" | cut -f1 -d' '); do /sbin/brctl show $br| grep -q $intf && sudo /sbin/brctl delif $br $intf \ && sudo /sbin/ip link set dev $br down && echo $intf deleted from $br done diff --git a/remove_modules.sh b/remove_modules.sh index b20edb1..197975b 100755 --- a/remove_modules.sh +++ b/remove_modules.sh @@ -1,15 +1,15 @@ -#!/bin/sh +#!/bin/sh -e # remove all external puppet modules PLUGIN_MOD_DIR="deployment_scripts/puppet/modules" -dir=`dirname $0` +dir=$(dirname $0) cd "${dir}" || exit 1 -cat Puppetfile | grep "^mod '" | awk -F "'" '{ print $2 }' | while read module; do +grep "^mod '" Puppetfile| awk -F "'" '{ print $2 }' | while read module; do if [ -d "${PLUGIN_MOD_DIR}/${module}" ]; then echo "Remove: ${PLUGIN_MOD_DIR}/${module}" - rm -rf "${PLUGIN_MOD_DIR}/${module}" + rm -rf "${PLUGIN_MOD_DIR:?}/${module}" fi done rm -f 'Puppetfile.lock' diff --git a/update_modules.sh b/update_modules.sh index 2bdf145..c869e10 100755 --- a/update_modules.sh +++ b/update_modules.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash -e ############################################################################### # # Copyright 2015 Mirantis, Inc. @@ -109,7 +109,7 @@ while getopts ":bp:g:h:vru:d:" opt; do done shift "$((OPTIND-1))" -DEPLOYMENT_DIR=$(cd `dirname $0` && pwd -P) +DEPLOYMENT_DIR=$(cd $(dirname $0) && pwd -P) # Timeout in seconds for running puppet librarian TIMEOUT=600 export PUPPET_GEM_VERSION=${PUPPET_GEM_VERSION:-'3.4.3'} @@ -128,7 +128,7 @@ if [ "$USE_BUNDLER" = true ]; then fi # if no timeout command, return true so we don't fail this script (LP#1510665) -TIMEOUT_CMD=`type -P timeout || true` +TIMEOUT_CMD=$(type -P timeout || true) if [ -n "$TIMEOUT_CMD" ]; then TIMEOUT_CMD="$TIMEOUT_CMD $TIMEOUT" fi