introduce if/then & for/do rules

we mostly have a consistent style on if/then & for/do in devstack,
except when we don't. This attempts to build a set of rules to
enforce this.

Because there are times when lines are legitimately long, and there
is a continuation, this starts off ignoring if and for loops with
continuations. But for short versions, we should enforce this.

Changes to make devstack pass are included. The fact that the
cleanup patch was so small is pretty solid reason that this is
actually the style we've all agreed to.

Part of a git stash from hong kong that I finally cleaned up.

Change-Id: I6376d7afd59cc5ebba9ed69e5ee784a3d5934a10
diff --git a/tools/xen/install_os_domU.sh b/tools/xen/install_os_domU.sh
index 41b184c..d172c7b 100755
--- a/tools/xen/install_os_domU.sh
+++ b/tools/xen/install_os_domU.sh
@@ -194,8 +194,7 @@
     while true
     do
         state=$(xe_min vm-list name-label="$GUEST_NAME" power-state=halted)
-        if [ -n "$state" ]
-        then
+        if [ -n "$state" ]; then
             break
         else
             echo -n "."
diff --git a/tools/xen/scripts/install-os-vpx.sh b/tools/xen/scripts/install-os-vpx.sh
index 7b0d891..8412fdc 100755
--- a/tools/xen/scripts/install-os-vpx.sh
+++ b/tools/xen/scripts/install-os-vpx.sh
@@ -63,8 +63,7 @@
                 ;;
         esac
     done
-    if [[ -z $BRIDGE ]]
-    then
+    if [[ -z $BRIDGE ]]; then
         BRIDGE=xenbr0
     fi
 
@@ -91,8 +90,7 @@
 find_network()
 {
     result=$(xe_min network-list bridge="$1")
-    if [ "$result" = "" ]
-    then
+    if [ "$result" = "" ]; then
         result=$(xe_min network-list name-label="$1")
     fi
     echo "$result"
@@ -121,8 +119,7 @@
 {
     local v="$1"
     IFS=,
-    for vif in $(xe_min vif-list vm-uuid="$v")
-    do
+    for vif in $(xe_min vif-list vm-uuid="$v"); do
         xe vif-destroy uuid="$vif"
     done
     unset IFS
diff --git a/tools/xen/scripts/on_exit.sh b/tools/xen/scripts/on_exit.sh
index a4db39c..2441e3d 100755
--- a/tools/xen/scripts/on_exit.sh
+++ b/tools/xen/scripts/on_exit.sh
@@ -7,8 +7,7 @@
 
 on_exit()
 {
-    for i in $(seq $((${#on_exit_hooks[*]} - 1)) -1 0)
-    do
+    for i in $(seq $((${#on_exit_hooks[*]} - 1)) -1 0); do
         eval "${on_exit_hooks[$i]}"
     done
 }
@@ -17,8 +16,7 @@
 {
     local n=${#on_exit_hooks[*]}
     on_exit_hooks[$n]="$*"
-    if [[ $n -eq 0 ]]
-    then
+    if [[ $n -eq 0 ]]; then
         trap on_exit EXIT
     fi
 }
diff --git a/tools/xen/test_functions.sh b/tools/xen/test_functions.sh
index 373d996..838f86a 100755
--- a/tools/xen/test_functions.sh
+++ b/tools/xen/test_functions.sh
@@ -227,16 +227,14 @@
 }
 
 [ "$1" = "run_tests" ] && {
-    for testname in $($0)
-    do
+    for testname in $($0); do
         echo "$testname"
         before_each_test
         (
             set -eux
             $testname
         )
-        if [ "$?" != "0" ]
-        then
+        if [ "$?" != "0" ]; then
             echo "FAIL"
             exit 1
         else