Skip to contentSkip to conversation

master - tests: scripts double quote

PATCH Zdenek Kabelac 1 participant 1 message Jul 10, 2017

lore
Share & tools
lore
#0 lore raw
Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=73bbd5528c2ccc9c5bdc4851e1c0b0ade19705ec
Commit:        73bbd5528c2ccc9c5bdc4851e1c0b0ade19705ec
Parent:        74ef5f07d0940a1ce784d569ce7d0bbeef74db87
Author:        Zdenek Kabelac <[email protected]>
AuthorDate:    Tue Jul 4 11:55:17 2017 +0200
Committer:     Zdenek Kabelac <[email protected]>
CommitterDate: Mon Jul 10 14:23:53 2017 +0200

tests: scripts double quote

---
 scripts/fsadm.sh         |    6 ++--
 scripts/lvmconf.sh       |   86 +++++++++++++++++++++++-----------------------
 scripts/lvmdump.sh.in    |    6 ++--
 scripts/vgimportclone.sh |   14 ++++----
 test/lib/aux.sh          |   32 ++++++++--------
 test/lib/check.sh        |   12 +++---
 test/lib/lvm-wrapper.sh  |    8 ++--
 7 files changed, 82 insertions(+), 82 deletions(-)
scripts/fsadm.sh +3 -3
index e08862a..459905f 100755
@@ -641,14 +641,14 @@ do
 	  "-e"|"--ext-offline") EXTOFF=1 ;;
 	  "-y"|"--yes") YES="-y" ;;
 	  "-l"|"--lvresize") DO_LVRESIZE=1 ;;
-	  "check") CHECK="$2" ; shift ;;
-	  "resize") RESIZE="$2"; NEWSIZE="$3" ; shift 2 ;;
+	  "check") CHECK=$2 ; shift ;;
+	  "resize") RESIZE=$2 ; NEWSIZE=$3 ; shift 2 ;;
 	  *) error "Wrong argument \"$1\". (see: $TOOL --help)"
 	esac
 	shift
 done
 
-test "$YES" = "-y" || YES=
+test "$YES" = "-y" || YES=""
 test "$EXTOFF" -eq 1 || EXTOFF=0
 
 if [ -n "$CHECK" ]; then
scripts/lvmconf.sh +43 -43

244 lines not on this page · raw message

scripts/lvmdump.sh.in +3 -3
index 4bef7df..24e3956 100644
@@ -100,7 +100,7 @@ done
 
 NOW=$("$DATE" -u +%G%m%d%k%M%S | "$TR" -d ' ')
 if test -n "$userdir"; then
-	dir="$userdir"
+	dir=$userdir
 else
 	dirbase="lvmdump-$HOSTNAME-$NOW"
 	dir="$HOME/$dirbase"
@@ -127,7 +127,7 @@ log() {
 }
 
 warnings() {
-	if test "$UID" != "0" && test "$EUID" != "0"; then
+	if test "$UID" != 0 && test "$EUID" != 0; then
 		myecho "WARNING! Running as non-privileged user, dump is likely incomplete!"
 	elif test "$DMSETUP" = ":"; then
 		myecho "WARNING! Could not run dmsetup, dump is likely incomplete."
@@ -163,7 +163,7 @@ if (( clustered )); then
 
 	{
 	for i in nodes status services; do
-		cap_i=$(echo $i|tr a-z A-Z)
+		cap_i=$(echo "$i"|tr a-z A-Z)
 		echo "$cap_i:"
 		echo "----------------------------------"
 		log "cman_tool $i 2>> \"$log\""
scripts/vgimportclone.sh +7 -7
index 783857e..061d0d3 100755
@@ -25,7 +25,7 @@ READLINK=readlink
 GETOPT=getopt
 
 # user may override lvm location by setting LVM_BINARY
-LVM="${LVM_BINARY:-lvm}"
+LVM=${LVM_BINARY:-lvm}
 
 die() {
     code=$1; shift
@@ -45,7 +45,7 @@ function getvgname {
     NEWVG=$3
 
     BNAME="${NEWVG:-${VG}}"
-    NAME="${BNAME}"
+    NAME=${BNAME}
     I=0
 
     while [[ "${VGLIST}" =~ :${NAME}: ]]
@@ -131,7 +131,7 @@ while true
 do
     case $1 in
         -n|--basevgname)
-            NEWVG="$2"; shift; shift
+            NEWVG=$2; shift; shift
             ;;
         -i|--import)
             IMPORT=1; shift
@@ -230,7 +230,7 @@ do
 done
 export FILTER="filter=[ ${FILTER} \"r|.*|\" ]"
 
-LVMCONF=${TMP_LVM_SYSTEM_DIR}/lvm.conf
+LVMCONF="${TMP_LVM_SYSTEM_DIR}/lvm.conf"
 
 CMD_CONFIG_LINE="devices { \
                    scan = [ \"${TMP_LVM_SYSTEM_DIR}\" ] \
@@ -278,7 +278,7 @@ while read -r VGNAME VGEXPORTED VGMISSINGPVCOUNT; do
     fi
 
     if [ "$VGEXPORTED" = "1" ]; then
-        if [ ${IMPORT} -eq 1 ]; then
+        if [ "${IMPORT}" -eq 1 ]; then
             "$LVM" vgimport ${LVM_OPTS} ${TEST_OPT} "${VGNAME}"
             checkvalue $? "Volume Group ${VGNAME} could not be imported"
         else
@@ -318,12 +318,12 @@ fi
 
 ### update the device cache and make sure all
 ### the device nodes we need are straight
-if [ ${CHANGES_MADE} -eq 1 ]
+if [ "${CHANGES_MADE}" -eq 1 ]
 then
     # get global/use_lvmetad config and if set also notify lvmetad about changes
     # since we were running LVM commands above with use_lvmetad=0
     eval "$("$LVM" dumpconfig ${LVM_OPTS} global/use_lvmetad)"
-    if [ "$use_lvmetad" = "1" ]
+    if [ "$use_lvmetad" = 1 ]
     then
       echo "Notifying lvmetad about changes since it was disabled temporarily."
       echo "(This resolves any WARNING message about restarting lvmetad that appears above.)"
test/lib/aux.sh +16 -16
index 13be7c5..d3e1af9 100644
@@ -22,31 +22,31 @@ expect_failure() {
 }
 
 COROSYNC_CONF="/etc/corosync/corosync.conf"
-COROSYNC_NODE="$(hostname)"
+COROSYNC_NODE=$(hostname)
 create_corosync_conf() {
-	if test -a $COROSYNC_CONF; then
-		if ! grep "created by lvm test suite" $COROSYNC_CONF; then
-			rm $COROSYNC_CONF
+	if test -a "$COROSYNC_CONF"; then
+		if ! grep "created by lvm test suite" "$COROSYNC_CONF"; then
+			rm "$COROSYNC_CONF"
 		else
-			mv $COROSYNC_CONF $COROSYNC_CONF.prelvmtest
+			mv "$COROSYNC_CONF" "$COROSYNC_CONF.prelvmtest"
 		fi
 	fi
 
-	sed -e "s/@LOCAL_NODE@/$COROSYNC_NODE/" lib/test-corosync-conf > $COROSYNC_CONF
+	sed -e "s/@LOCAL_NODE@/$COROSYNC_NODE/" lib/test-corosync-conf > "$COROSYNC_CONF"
 	echo "created new $COROSYNC_CONF"
 }
 
 DLM_CONF="/etc/dlm/dlm.conf"
 create_dlm_conf() {
-	if test -a $DLM_CONF; then
-		if ! grep "created by lvm test suite" $DLM_CONF; then
-			rm $DLM_CONF
+	if test -a "$DLM_CONF"; then
+		if ! grep "created by lvm test suite" "$DLM_CONF"; then
+			rm "$DLM_CONF"
 		else
-			mv $DLM_CONF $DLM_CONF.prelvmtest
+			mv "$DLM_CONF" "$DLM_CONF.prelvmtest"
 		fi
 	fi
 
-	cp lib/test-dlm-conf $DLM_CONF
+	cp lib/test-dlm-conf "$DLM_CONF"
 	echo "created new $DLM_CONF"
 }
 
@@ -81,15 +81,15 @@ prepare_dlm() {
 
 SANLOCK_CONF="/etc/sanlock/sanlock.conf"
 create_sanlock_conf() {
-	if test -a $SANLOCK_CONF; then
-		if ! grep "created by lvm test suite" $SANLOCK_CONF; then
-			rm $SANLOCK_CONF
+	if test -a "$SANLOCK_CONF"; then
+		if ! grep "created by lvm test suite" "$SANLOCK_CONF"; then
+			rm "$SANLOCK_CONF"
 		else
-			mv $SANLOCK_CONF $SANLOCK_CONF.prelvmtest
+			mv "$SANLOCK_CONF" "$SANLOCK_CONF.prelvmtest"
 		fi
 	fi
 
-	cp lib/test-sanlock-conf $SANLOCK_CONF
+	cp lib/test-sanlock-conf "$SANLOCK_CONF"
 	echo "created new $SANLOCK_CONF"
 }
 
test/lib/check.sh +6 -6
index a7653b5..603f334 100644
@@ -40,7 +40,7 @@ lvdevices() {
 
 mirror_images_redundant() {
 	local vg=$1
-	local lv=$vg/$2
+	local lv="$vg/$2"
 	lvs -a "$vg" -o+devices
 	for i in $(lvdevices "$lv"); do
 		echo "# $i:"
@@ -77,7 +77,7 @@ lv_on() {
 
 	devs=( $(lvdevices "$1/$2" | sort | uniq ) )
 
-	lv_on_diff_ devs[@] "${@}"
+	lv_on_diff_ devs[@] "$@"
 }
 
 # list devices for given LV and all its subdevices
@@ -87,7 +87,7 @@ lv_tree_on() {
 	# Get sorted list of devices
 	devs=( $(get lv_tree_devices "$1" "$2") )
 
-	lv_on_diff_ devs[@] "${@}"
+	lv_on_diff_ devs[@] "$@"
 }
 
 mirror_images_on() {
@@ -112,14 +112,14 @@ mirror_log_on() {
 }
 
 lv_is_contiguous() {
-	local lv=$1/$2
+	local lv="$1/$2"
 	test "$(lvl --segments "$lv" | wc -l)" -eq 1 || \
 		die "LV $lv expected to be contiguous, but is not:" \
 			"$(lvl --segments "$lv")"
 }
 
 lv_is_clung() {
-	local lv=$1/$2
+	local lv="$1/$2"
 	test "$(lvdevices "$lv" | sort | uniq | wc -l)" -eq 1 || \
 		die "LV $lv expected to be clung, but is not:" \
 			"$(lvdevices "$lv" | sort | uniq)"
@@ -188,7 +188,7 @@ in_sync() {
 	local type
 	local snap=""
 	local lvm_name="$1/$2"
-	local ignore_a="$3"
+	local ignore_a=$3
 	local dm_name
 
 	dm_name=$(echo "$lvm_name" | sed s:-:--: | sed s:/:-:)
test/lib/lvm-wrapper.sh +4 -4
index 129cafe..469154a 100644
@@ -1,5 +1,5 @@
 #!/bin/sh
-# Copyright (C) 2011-2014 Red Hat, Inc.
+# Copyright (C) 2011-2017 Red Hat, Inc.
 #
 # This copyrighted material is made available to anyone wishing to use,
 # modify, copy, or redistribute it subject to the terms and conditions
@@ -33,9 +33,9 @@ fi
 
 case "$CMD" in
   lvs|pvs|vgs|vgck|vgscan)
-	test "${LVM_DEBUG_LEVEL:-0}" -lt 2 && RUN_DBG= ;;
+	test "${LVM_DEBUG_LEVEL:-0}" -lt 2 && RUN_DBG="" ;;
   pvcreate|pvremove|lvremove|vgcreate|vgremove)
-	test "${LVM_DEBUG_LEVEL:-0}" -lt 1 && RUN_DBG= ;;
+	test "${LVM_DEBUG_LEVEL:-0}" -lt 1 && RUN_DBG="" ;;
 esac
 
 # Capture parallel users of debug.log file
@@ -48,6 +48,6 @@ esac
 if test -n "$abs_top_builddir"; then
     exec $RUN_DBG "$abs_top_builddir/tools/lvm" $CMD "$@"
 else # we are testing the lvm on $PATH
-    PATH=$(echo "$PATH" | sed -e s,[^:]*lvm2-testsuite[^:]*:,,g)
+    PATH=$(echo "$PATH" | sed -e 's,[^:]*lvm2-testsuite[^:]*:,,g')
     exec $RUN_DBG lvm $CMD "$@"
 fi