[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[virt-tools-list] [PATCH] use brackets for shell va riables



---
 tests/test-baremetal.sh               | 10 ++---
 tests/test-esx4.1.sh                  | 10 ++---
 tests/test-hyperv.sh                  | 10 ++---
 tests/test-kvm-explicit-cpu.sh        | 10 ++---
 tests/test-kvm.sh                     | 10 ++---
 tests/test-linux-vserver.sh           | 10 ++---
 tests/test-lx86.sh                    | 10 ++---
 tests/test-parallels-desktop.sh       | 10 ++---
 tests/test-qemu.sh                    | 10 ++---
 tests/test-rhel5-xen-dom0.sh          | 10 ++---
 tests/test-rhel5-xen-domU-hvm-ia64.sh | 10 ++---
 tests/test-rhel5-xen-domU-hvm.sh      | 10 ++---
 tests/test-rhel5-xen-domU-pv.sh       | 10 ++---
 tests/test-zvm.sh                     | 10 ++---
 virt-what.in                          | 76 +++++++++++++++++------------------
 15 files changed, 108 insertions(+), 108 deletions(-)

diff --git a/tests/test-baremetal.sh b/tests/test-baremetal.sh
index 1ca4bcf..cdee224 100755
--- a/tests/test-baremetal.sh
+++ b/tests/test-baremetal.sh
@@ -17,18 +17,18 @@
 
 root=tests/baremetal
 
-output="$(./virt-what --test-root=$root 2>&1)"
+output="$(./virt-what --test-root=${root} 2>&1)"
 expected=""
 
-if [ "$output" != "$expected" ]; then
-    echo "$0: test failed because output did not match expected"
+if [ "${output}" != "${expected}" ]; then
+    echo "${0}: test failed because output did not match expected"
     echo "Expected output was:"
     echo "----------------------------------------"
-    echo "$expected"
+    echo "${expected}"
     echo "----------------------------------------"
     echo "But the actual output of the program was:"
     echo "----------------------------------------"
-    echo "$output"
+    echo "${output}"
     echo "----------------------------------------"
     exit 1
 fi
diff --git a/tests/test-esx4.1.sh b/tests/test-esx4.1.sh
index 35c4e1d..a780ae2 100755
--- a/tests/test-esx4.1.sh
+++ b/tests/test-esx4.1.sh
@@ -18,18 +18,18 @@
 
 root=tests/esx4.1
 
-output="$(./virt-what --test-root=$root 2>&1)"
+output="$(./virt-what --test-root=${root} 2>&1)"
 expected="vmware"
 
-if [ "$output" != "$expected" ]; then
-    echo "$0: test failed because output did not match expected"
+if [ "${output}" != "${expected}" ]; then
+    echo "${0}: test failed because output did not match expected"
     echo "Expected output was:"
     echo "----------------------------------------"
-    echo "$expected"
+    echo "${expected}"
     echo "----------------------------------------"
     echo "But the actual output of the program was:"
     echo "----------------------------------------"
-    echo "$output"
+    echo "${output}"
     echo "----------------------------------------"
     exit 1
 fi
diff --git a/tests/test-hyperv.sh b/tests/test-hyperv.sh
index 5015cc5..2bfe448 100755
--- a/tests/test-hyperv.sh
+++ b/tests/test-hyperv.sh
@@ -17,18 +17,18 @@
 
 root=tests/hyperv
 
-output="$(./virt-what --test-root=$root 2>&1)"
+output="$(./virt-what --test-root=${root} 2>&1)"
 expected="hyperv"
 
-if [ "$output" != "$expected" ]; then
-    echo "$0: test failed because output did not match expected"
+if [ "${output}" != "${expected}" ]; then
+    echo "${0}: test failed because output did not match expected"
     echo "Expected output was:"
     echo "----------------------------------------"
-    echo "$expected"
+    echo "${expected}"
     echo "----------------------------------------"
     echo "But the actual output of the program was:"
     echo "----------------------------------------"
-    echo "$output"
+    echo "${output}"
     echo "----------------------------------------"
     exit 1
 fi
diff --git a/tests/test-kvm-explicit-cpu.sh b/tests/test-kvm-explicit-cpu.sh
index 7482b83..686cf7c 100755
--- a/tests/test-kvm-explicit-cpu.sh
+++ b/tests/test-kvm-explicit-cpu.sh
@@ -17,18 +17,18 @@
 
 root=tests/kvm-explicit-cpu
 
-output="$(./virt-what --test-root=$root 2>&1)"
+output="$(./virt-what --test-root=${root} 2>&1)"
 expected="kvm"
 
-if [ "$output" != "$expected" ]; then
-    echo "$0: test failed because output did not match expected"
+if [ "${output}" != "${expected}" ]; then
+    echo "${0}: test failed because output did not match expected"
     echo "Expected output was:"
     echo "----------------------------------------"
-    echo "$expected"
+    echo "${expected}"
     echo "----------------------------------------"
     echo "But the actual output of the program was:"
     echo "----------------------------------------"
-    echo "$output"
+    echo "${output}"
     echo "----------------------------------------"
     exit 1
 fi
diff --git a/tests/test-kvm.sh b/tests/test-kvm.sh
index 035e244..96e8fd6 100755
--- a/tests/test-kvm.sh
+++ b/tests/test-kvm.sh
@@ -17,18 +17,18 @@
 
 root=tests/kvm
 
-output="$(./virt-what --test-root=$root 2>&1)"
+output="$(./virt-what --test-root=${root} 2>&1)"
 expected="kvm"
 
-if [ "$output" != "$expected" ]; then
-    echo "$0: test failed because output did not match expected"
+if [ "${output}" != "${expected}" ]; then
+    echo "${0}: test failed because output did not match expected"
     echo "Expected output was:"
     echo "----------------------------------------"
-    echo "$expected"
+    echo "${expected}"
     echo "----------------------------------------"
     echo "But the actual output of the program was:"
     echo "----------------------------------------"
-    echo "$output"
+    echo "${output}"
     echo "----------------------------------------"
     exit 1
 fi
diff --git a/tests/test-linux-vserver.sh b/tests/test-linux-vserver.sh
index 40d75a5..1c78362 100755
--- a/tests/test-linux-vserver.sh
+++ b/tests/test-linux-vserver.sh
@@ -18,18 +18,18 @@
 
 root=tests/linux-vserver
 
-output="$(./virt-what --test-root=$root 2>&1)"
+output="$(./virt-what --test-root=${root} 2>&1)"
 expected="linux_vserver"
 
-if [ "$output" != "$expected" ]; then
-    echo "$0: test failed because output did not match expected"
+if [ "${output}" != "${expected}" ]; then
+    echo "${0}: test failed because output did not match expected"
     echo "Expected output was:"
     echo "----------------------------------------"
-    echo "$expected"
+    echo "${expected}"
     echo "----------------------------------------"
     echo "But the actual output of the program was:"
     echo "----------------------------------------"
-    echo "$output"
+    echo "${output}"
     echo "----------------------------------------"
     exit 1
 fi
diff --git a/tests/test-lx86.sh b/tests/test-lx86.sh
index 69d08a7..25b6455 100755
--- a/tests/test-lx86.sh
+++ b/tests/test-lx86.sh
@@ -18,18 +18,18 @@
 
 root=tests/lx86
 
-output="$(./virt-what --test-root=$root 2>&1)"
+output="$(./virt-what --test-root=${root} 2>&1)"
 expected="powervm_lx86"
 
-if [ "$output" != "$expected" ]; then
-    echo "$0: test failed because output did not match expected"
+if [ "${output}" != "${expected}" ]; then
+    echo "${0}: test failed because output did not match expected"
     echo "Expected output was:"
     echo "----------------------------------------"
-    echo "$expected"
+    echo "${expected}"
     echo "----------------------------------------"
     echo "But the actual output of the program was:"
     echo "----------------------------------------"
-    echo "$output"
+    echo "${output}"
     echo "----------------------------------------"
     exit 1
 fi
diff --git a/tests/test-parallels-desktop.sh b/tests/test-parallels-desktop.sh
index 20701fe..5641a50 100755
--- a/tests/test-parallels-desktop.sh
+++ b/tests/test-parallels-desktop.sh
@@ -18,18 +18,18 @@
 
 root=tests/parallels-desktop
 
-output="$(./virt-what --test-root=$root 2>&1)"
+output="$(./virt-what --test-root=${root} 2>&1)"
 expected="parallels"
 
-if [ "$output" != "$expected" ]; then
-    echo "$0: test failed because output did not match expected"
+if [ "${output}" != "${expected}" ]; then
+    echo "${0}: test failed because output did not match expected"
     echo "Expected output was:"
     echo "----------------------------------------"
-    echo "$expected"
+    echo "${expected}"
     echo "----------------------------------------"
     echo "But the actual output of the program was:"
     echo "----------------------------------------"
-    echo "$output"
+    echo "${output}"
     echo "----------------------------------------"
     exit 1
 fi
diff --git a/tests/test-qemu.sh b/tests/test-qemu.sh
index 284fe41..63fb115 100755
--- a/tests/test-qemu.sh
+++ b/tests/test-qemu.sh
@@ -17,18 +17,18 @@
 
 root=tests/qemu
 
-output="$(./virt-what --test-root=$root 2>&1)"
+output="$(./virt-what --test-root=${root} 2>&1)"
 expected="qemu"
 
-if [ "$output" != "$expected" ]; then
-    echo "$0: test failed because output did not match expected"
+if [ "${output}" != "${expected}" ]; then
+    echo "${0}: test failed because output did not match expected"
     echo "Expected output was:"
     echo "----------------------------------------"
-    echo "$expected"
+    echo "${expected}"
     echo "----------------------------------------"
     echo "But the actual output of the program was:"
     echo "----------------------------------------"
-    echo "$output"
+    echo "${output}"
     echo "----------------------------------------"
     exit 1
 fi
diff --git a/tests/test-rhel5-xen-dom0.sh b/tests/test-rhel5-xen-dom0.sh
index 6571ecd..a75416a 100755
--- a/tests/test-rhel5-xen-dom0.sh
+++ b/tests/test-rhel5-xen-dom0.sh
@@ -17,19 +17,19 @@
 
 root=tests/rhel5-xen-dom0
 
-output="$(./virt-what --test-root=$root 2>&1)"
+output="$(./virt-what --test-root=${root} 2>&1)"
 expected="xen
 xen-dom0"
 
-if [ "$output" != "$expected" ]; then
-    echo "$0: test failed because output did not match expected"
+if [ "${output}" != "${expected}" ]; then
+    echo "${0}: test failed because output did not match expected"
     echo "Expected output was:"
     echo "----------------------------------------"
-    echo "$expected"
+    echo "${expected}"
     echo "----------------------------------------"
     echo "But the actual output of the program was:"
     echo "----------------------------------------"
-    echo "$output"
+    echo "${output}"
     echo "----------------------------------------"
     exit 1
 fi
diff --git a/tests/test-rhel5-xen-domU-hvm-ia64.sh b/tests/test-rhel5-xen-domU-hvm-ia64.sh
index 5f29c1b..1b832f0 100755
--- a/tests/test-rhel5-xen-domU-hvm-ia64.sh
+++ b/tests/test-rhel5-xen-domU-hvm-ia64.sh
@@ -17,19 +17,19 @@
 
 root=tests/rhel5-xen-domU-hvm-ia64
 
-output="$(./virt-what --test-root=$root 2>&1)"
+output="$(./virt-what --test-root=${root} 2>&1)"
 expected="xen
 xen-hvm"
 
-if [ "$output" != "$expected" ]; then
-    echo "$0: test failed because output did not match expected"
+if [ "${output}" != "${expected}" ]; then
+    echo "${0}: test failed because output did not match expected"
     echo "Expected output was:"
     echo "----------------------------------------"
-    echo "$expected"
+    echo "${expected}"
     echo "----------------------------------------"
     echo "But the actual output of the program was:"
     echo "----------------------------------------"
-    echo "$output"
+    echo "${output}"
     echo "----------------------------------------"
     exit 1
 fi
diff --git a/tests/test-rhel5-xen-domU-hvm.sh b/tests/test-rhel5-xen-domU-hvm.sh
index 593fdb7..a611f0e 100755
--- a/tests/test-rhel5-xen-domU-hvm.sh
+++ b/tests/test-rhel5-xen-domU-hvm.sh
@@ -17,19 +17,19 @@
 
 root=tests/rhel5-xen-domU-hvm
 
-output="$(./virt-what --test-root=$root 2>&1)"
+output="$(./virt-what --test-root=${root} 2>&1)"
 expected="xen
 xen-hvm"
 
-if [ "$output" != "$expected" ]; then
-    echo "$0: test failed because output did not match expected"
+if [ "${output}" != "${expected}" ]; then
+    echo "${0}: test failed because output did not match expected"
     echo "Expected output was:"
     echo "----------------------------------------"
-    echo "$expected"
+    echo "${expected}"
     echo "----------------------------------------"
     echo "But the actual output of the program was:"
     echo "----------------------------------------"
-    echo "$output"
+    echo "${output}"
     echo "----------------------------------------"
     exit 1
 fi
diff --git a/tests/test-rhel5-xen-domU-pv.sh b/tests/test-rhel5-xen-domU-pv.sh
index 6561605..15b8e6d 100755
--- a/tests/test-rhel5-xen-domU-pv.sh
+++ b/tests/test-rhel5-xen-domU-pv.sh
@@ -17,19 +17,19 @@
 
 root=tests/rhel5-xen-domU-pv
 
-output="$(./virt-what --test-root=$root 2>&1)"
+output="$(./virt-what --test-root=${root} 2>&1)"
 expected="xen
 xen-domU"
 
-if [ "$output" != "$expected" ]; then
-    echo "$0: test failed because output did not match expected"
+if [ "${output}" != "${expected}" ]; then
+    echo "${0}: test failed because output did not match expected"
     echo "Expected output was:"
     echo "----------------------------------------"
-    echo "$expected"
+    echo "${expected}"
     echo "----------------------------------------"
     echo "But the actual output of the program was:"
     echo "----------------------------------------"
-    echo "$output"
+    echo "${output}"
     echo "----------------------------------------"
     exit 1
 fi
diff --git a/tests/test-zvm.sh b/tests/test-zvm.sh
index 0620db0..4bd29f7 100755
--- a/tests/test-zvm.sh
+++ b/tests/test-zvm.sh
@@ -18,19 +18,19 @@
 
 root=tests/zvm
 
-output="$(./virt-what --test-root=$root 2>&1)"
+output="$(./virt-what --test-root=${root} 2>&1)"
 expected="ibm_systemz
 ibm_systemz-zvm"
 
-if [ "$output" != "$expected" ]; then
-    echo "$0: test failed because output did not match expected"
+if [ "${output}" != "${expected}" ]; then
+    echo "${0}: test failed because output did not match expected"
     echo "Expected output was:"
     echo "----------------------------------------"
-    echo "$expected"
+    echo "${expected}"
     echo "----------------------------------------"
     echo "But the actual output of the program was:"
     echo "----------------------------------------"
-    echo "$output"
+    echo "${output}"
     echo "----------------------------------------"
     exit 1
 fi
diff --git a/virt-what.in b/virt-what.in
index 21488e7..f77a68d 100644
--- a/virt-what.in
+++ b/virt-what.in
@@ -34,7 +34,7 @@ skip_qemu_kvm=false
 VERSION="@VERSION@"
 
 function fail {
-    echo "virt-what: $1"
+    echo "virt-what: ${1}"
     exit 1
 }
 
@@ -48,21 +48,21 @@ function usage {
 
 # Handle the command line arguments, if any.
 
-TEMP=$(getopt -o v --long help --long version --long test-root: -n 'virt-what' -- "$@")
-if [ $? != 0 ]; then exit 1; fi
-eval set -- "$TEMP"
+TEMP=$(getopt -o v --long help --long version --long test-root: -n 'virt-what' -- "${ }")
+if [ ${?} != 0 ]; then exit 1; fi
+eval set -- "${TEMP}"
 
 while true; do
-    case "$1" in
+    case "${1}" in
 	--help) usage ;;
         --test-root)
             # Deliberately undocumented: used for 'make check'.
-            root="$2"
+            root="${2}"
             shift 2
             ;;
-	-v|--version) echo $VERSION; exit 0 ;;
+	-v|--version) echo ${VERSION}; exit 0 ;;
 	--) shift; break ;;
-	*) fail "internal error ($1)" ;;
+	*) fail "internal error (${1})" ;;
     esac
 done
 
@@ -71,11 +71,11 @@ done
 # Add /usr/libexec to the path so we can find the helper binary.
 prefix= prefix@
 exec_prefix= exec_prefix@
-PATH=$root libexecdir@:$root/sbin:$root/usr/sbin:$PATH
+PATH=${root} libexecdir@:${root}/sbin:${root}/usr/sbin:${PATH}
 
 # Check we're running as root.
 
-if [ "x$root" = "x" ] && [ "$EUID" -ne 0 ]; then
+if [ "x${root}" = "x" ] && [ "${EUID}" -ne 0 ]; then
     fail "this script must be run as root"
 fi
 
@@ -99,29 +99,29 @@ arch=$(uname -p)
 # Check for VMware.
 # cpuid check added by Chetan Loke.
 
-if [ "$cpuid" = "VMwareVMware" ]; then
+if [ "${cpuid}" = "VMwareVMware" ]; then
     echo vmware
-elif echo "$dmi" | grep -q 'Manufacturer: VMware'; then
+elif echo "${dmi}" | grep -q 'Manufacturer: VMware'; then
     echo vmware
 fi
 
 # Check for Hyper-V.
 # http://blogs.msdn.com/b/sqlosteam/archive/2010/10/30/is-this-real-the-metaphysics-of-hardware-virtualization.aspx
-if [ "$cpuid" = "Microsoft Hv" ]; then
+if [ "${cpuid}" = "Microsoft Hv" ]; then
     echo hyperv
 fi
 
 # Check for VirtualPC.
 # The negative check for cpuid is to distinguish this from Hyper-V
 # which also has the same manufacturer string in the SM-BIOS data.
-if [ "$cpuid" != "Microsoft Hv" ] &&
-    echo "$dmi" | grep -q 'Manufacturer: Microsoft Corporation'; then
+if [ "${cpuid}" != "Microsoft Hv" ] &&
+    echo "${dmi}" | grep -q 'Manufacturer: Microsoft Corporation'; then
     echo virtualpc
 fi
 
 # Check for VirtualBox.
 # Added by Laurent Léonard.
-if echo "$dmi" | grep -q 'Manufacturer: innotek GmbH'; then
+if echo "${dmi}" | grep -q 'Manufacturer: innotek GmbH'; then
     echo virtualbox
 fi
 
@@ -131,39 +131,39 @@ fi
 # container)
 # /proc/bc - exists on node, but not inside container.
 
-if [ -d $root/proc/vz -a ! -d $root/proc/bc ]; then
+if [ -d ${root}/proc/vz -a ! -d ${root}/proc/bc ]; then
     echo openvz
 fi
 
 # Check for Linux-VServer
-if cat $root/proc/self/status | grep -q "VxID: [0-9]*"; then
+if cat ${root}/proc/self/status | grep -q "VxID: [0-9]*"; then
     echo linux_vserver
 fi
 
 # Check for UML.
 # Added by Laurent Léonard.
-if grep -q 'UML' $root/proc/cpuinfo; then
+if grep -q 'UML' ${root}/proc/cpuinfo; then
     echo uml
 fi
 
 # Check for IBM PowerVM Lx86 Linux/x86 emulator.
-if grep -q '^vendor_id.*PowerVM Lx86' $root/proc/cpuinfo; then
+if grep -q '^vendor_id.*PowerVM Lx86' ${root}/proc/cpuinfo; then
     echo powervm_lx86
 fi
 
 # Check for Hitachi Virtualization Manager (HVM) Virtage logical partitioning.
-if echo "$dmi" | grep -q 'Manufacturer.*HITACHI' &&
-   echo "$dmi" | grep -q 'Product.* LPAR'; then
+if echo "${dmi}" | grep -q 'Manufacturer.*HITACHI' &&
+   echo "${dmi}" | grep -q 'Product.* LPAR'; then
     echo virtage
 fi
 
 # Check for IBM SystemZ.
-if grep -q '^vendor_id.*IBM/S390' $root/proc/cpuinfo; then
+if grep -q '^vendor_id.*IBM/S390' ${root}/proc/cpuinfo; then
     echo ibm_systemz
-    if [ -f $root/proc/sysinfo ]; then
-        if grep -q 'VM.*Control Program.*z/VM' $root/proc/sysinfo; then
+    if [ -f ${root}/proc/sysinfo ]; then
+        if grep -q 'VM.*Control Program.*z/VM' ${root}/proc/sysinfo; then
             echo ibm_systemz-zvm
-        elif grep -q '^LPAR' $root/proc/sysinfo; then
+        elif grep -q '^LPAR' ${root}/proc/sysinfo; then
             echo ibm_systemz-lpar
         else
             # This is unlikely to be correct.
@@ -173,32 +173,32 @@ if grep -q '^vendor_id.*IBM/S390' $root/proc/cpuinfo; then
 fi
 
 # Check for Parallels.
-if echo "$dmi" | grep -q 'Vendor: Parallels'; then
+if echo "${dmi}" | grep -q 'Vendor: Parallels'; then
     echo parallels
     skip_qemu_kvm=true
 fi
 
 # Check for Xen.
 
-if [ "$cpuid" = "XenVMMXenVMM" ]; then
+if [ "${cpuid}" = "XenVMMXenVMM" ]; then
     echo xen; echo xen-hvm
     skip_qemu_kvm=true
-elif [ -f $root/proc/xen/capabilities ]; then
+elif [ -f ${root}/proc/xen/capabilities ]; then
     echo xen
-    if grep -q "control_d" $root/proc/xen/capabilities; then
+    if grep -q "control_d" ${root}/proc/xen/capabilities; then
         echo xen-dom0
     else
         echo xen-domU
     fi
     skip_qemu_kvm=true
-elif [ -f $root/sys/hypervisor/type ] &&
-    grep -q "xen" $root/sys/hypervisor/type; then
+elif [ -f ${root}/sys/hypervisor/type ] &&
+    grep -q "xen" ${root}/sys/hypervisor/type; then
     # Ordinary kernel with pv_ops.  There does not seem to be
     # enough information at present to tell whether this is dom0
     # or domU.  XXX
     echo xen
-elif [ "$arch" = "ia64" ]; then
-    if [ -d $root/sys/bus/xen -a ! -d $root/sys/bus/xen-backend ]; then
+elif [ "${arch}" = "ia64" ]; then
+    if [ -d ${root}/sys/bus/xen -a ! -d ${root}/sys/bus/xen-backend ]; then
         # PV-on-HVM drivers installed in a Xen guest.
         echo xen
         echo xen-hvm
@@ -207,7 +207,7 @@ elif [ "$arch" = "ia64" ]; then
         # attempt to detect something is virtualized by using a
         # timing attack.
         virt-what-ia64-xen-rdtsc-test > /dev/null 2>&1
-        case "$?" in
+        case "${?}" in
             0) ;; # not virtual
             1) # Could be some sort of virt, or could just be a bit slow.
                 echo virt
@@ -221,15 +221,15 @@ fi
 # seen that it's Parallels.  Xen uses QEMU as the device model, so
 # skip this test if we know it is Xen.
 
-if ! $skip_qemu_kvm; then
-    if [ "$cpuid" = "KVMKVMKVM" ]; then
+if ! ${skip_qemu_kvm}; then
+    if [ "${cpuid}" = "KVMKVMKVM" ]; then
 	echo kvm
     else
         # XXX This is known to fail for qemu with the explicit -cpu
         # option, since /proc/cpuinfo will not contain the QEMU
         # string.  The long term fix for this would be to export
         # another CPUID leaf for non-accelerated qemu.
-        if grep -q 'QEMU' $root/proc/cpuinfo; then
+        if grep -q 'QEMU' ${root}/proc/cpuinfo; then
 	    echo qemu
 	fi
     fi
-- 
1.7.12.4


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]