From d06a1caafbed32e444cdc2dc9fa2fb2c64f9566a Mon Sep 17 00:00:00 2001
From: AzherKhan <azher-ullah.khan@hp.com>
Date: Tue, 1 Jul 2014 02:27:41 -0700
Subject: [PATCH] Correction: if then statement code style.

Corrected the if; then statement to follow bash convention.

Change-Id: Ia3f80520bb9446c4feb5ce36dccffa2b1c1d72c4
---
 README.md                                              | 10 ++++++----
 bin/disk-image-create                                  |  3 +--
 bin/disk-image-get-kernel                              |  3 +--
 elements/dpkg/cleanup.d/40-unblock-daemons             |  3 +--
 elements/dpkg/root.d/99-block-daemons                  |  3 +--
 .../finalise.d/99-redhat-setup-first-boot              |  6 ++----
 elements/rhel/pre-install.d/00-rhsm                    |  3 +--
 lib/common-functions                                   |  3 +--
 lib/img-functions                                      |  2 +-
 9 files changed, 15 insertions(+), 21 deletions(-)

diff --git a/README.md b/README.md
index 5551839dc..9bd770ae7 100644
--- a/README.md
+++ b/README.md
@@ -368,12 +368,14 @@ Ramdisk elements support the following files in their element directories:
 
 * udev.d : udev rules files that will be copied into the ramdisk.
 
-### Whitespace Rules
+### Element coding standard ###
 
-- lines should not include trailing whitespace
-- there should be no hard tabs in the file
+- lines should not include trailing whitespace.
+- there should be no hard tabs in the file.
 - indents are 4 spaces, and all indentation should be some multiple of
-  them
+  them.
+- `do` and `then` keywords should be on the same line as the if, while or
+  for conditions.
 
 Global image-build variables
 ----------------------------
diff --git a/bin/disk-image-create b/bin/disk-image-create
index 90b5ef9ab..03333b460 100755
--- a/bin/disk-image-create
+++ b/bin/disk-image-create
@@ -26,8 +26,7 @@ export DIB_ENV=$(export | grep ' DIB_.*=')
 
 SCRIPTNAME=$(basename $0)
 SCRIPT_HOME=$(dirname $0)
-if [ -d $SCRIPT_HOME/../share/diskimage-builder ]
-then
+if [ -d $SCRIPT_HOME/../share/diskimage-builder ]; then
     export _PREFIX=$SCRIPT_HOME/../share/diskimage-builder
 else
     export _PREFIX=$SCRIPT_HOME/..
diff --git a/bin/disk-image-get-kernel b/bin/disk-image-get-kernel
index 7fa6785f9..a47966926 100755
--- a/bin/disk-image-get-kernel
+++ b/bin/disk-image-get-kernel
@@ -18,8 +18,7 @@ set -e
 
 SCRIPTNAME=$(basename $0)
 SCRIPT_HOME=$(dirname $0)
-if [ -d $SCRIPT_HOME/../share/diskimage-builder ]
-then
+if [ -d $SCRIPT_HOME/../share/diskimage-builder ]; then
     export _PREFIX=$SCRIPT_HOME/../share/diskimage-builder
 else
     export _PREFIX=$SCRIPT_HOME/..
diff --git a/elements/dpkg/cleanup.d/40-unblock-daemons b/elements/dpkg/cleanup.d/40-unblock-daemons
index b9712fd36..b60960e78 100755
--- a/elements/dpkg/cleanup.d/40-unblock-daemons
+++ b/elements/dpkg/cleanup.d/40-unblock-daemons
@@ -7,8 +7,7 @@ set -o pipefail
 
 sudo mv $TARGET_ROOT/sbin/start-stop-daemon.REAL $TARGET_ROOT/sbin/start-stop-daemon
 
-if [ -f $TARGET_ROOT/sbin/initctl.REAL ]
-then
+if [ -f $TARGET_ROOT/sbin/initctl.REAL ]; then
     sudo mv $TARGET_ROOT/sbin/initctl.REAL $TARGET_ROOT/sbin/initctl
 fi
 
diff --git a/elements/dpkg/root.d/99-block-daemons b/elements/dpkg/root.d/99-block-daemons
index 4663013f8..adb673d97 100755
--- a/elements/dpkg/root.d/99-block-daemons
+++ b/elements/dpkg/root.d/99-block-daemons
@@ -14,8 +14,7 @@ echo "Warning: Fake start-stop-daemon called, doing nothing"
 EOF
 sudo chmod 755 $TARGET_ROOT/sbin/start-stop-daemon
 
-if [ -f $TARGET_ROOT/sbin/initctl ]
-then
+if [ -f $TARGET_ROOT/sbin/initctl ]; then
     sudo mv $TARGET_ROOT/sbin/initctl $TARGET_ROOT/sbin/initctl.REAL
     sudo dd of=$TARGET_ROOT/sbin/initctl <<EOF
 #!/bin/sh
diff --git a/elements/redhat-common/finalise.d/99-redhat-setup-first-boot b/elements/redhat-common/finalise.d/99-redhat-setup-first-boot
index 0211d8950..d8db35a5e 100755
--- a/elements/redhat-common/finalise.d/99-redhat-setup-first-boot
+++ b/elements/redhat-common/finalise.d/99-redhat-setup-first-boot
@@ -6,8 +6,7 @@ if [ -d /etc/first-boot.d ]; then
     rc_local=/etc/rc.d/rc.local
 
     FILE_EXISTED=
-    if [ -f $rc_local ]
-    then
+    if [ -f $rc_local ]; then
         FILE_EXISTED=1
         mv $rc_local $rc_local.REAL
     fi
@@ -20,8 +19,7 @@ set -o xtrace
 dib-first-boot
 EOF
 
-if [ $FILE_EXISTED ]
-then
+if [ $FILE_EXISTED ]; then
     echo "mv $rc_local.REAL $rc_local" >> $rc_local
 else
     echo "rm \$0" >> $rc_local
diff --git a/elements/rhel/pre-install.d/00-rhsm b/elements/rhel/pre-install.d/00-rhsm
index 70410c057..db1dd24de 100755
--- a/elements/rhel/pre-install.d/00-rhsm
+++ b/elements/rhel/pre-install.d/00-rhsm
@@ -5,8 +5,7 @@ set -o pipefail
 
 export DIB_RHSM_USER=${DIB_RHSM_USER:-}
 
-if [ -n "$DIB_RHSM_USER" ] && [ -n "$DIB_RHSM_PASSWORD" ]
-then
+if [ -n "$DIB_RHSM_USER" ] && [ -n "$DIB_RHSM_PASSWORD" ] ; then
     opts="--force"
     if [[ -n "$DIB_SAT_KEY" ]]; then
         opts="$opts --activationkey ${DIB_SAT_KEY}"
diff --git a/lib/common-functions b/lib/common-functions
index ac66b5a82..c9efe8933 100644
--- a/lib/common-functions
+++ b/lib/common-functions
@@ -275,8 +275,7 @@ function create_base () {
     sudo touch $TMP_MOUNT_PATH/etc/resolv.conf
     sudo chmod 777 $TMP_MOUNT_PATH/etc/resolv.conf
     # use system configured resolv.conf if available to support internal proxy resolving
-    if [ -e /etc/resolv.conf ]
-    then
+    if [ -e /etc/resolv.conf ]; then
         cat /etc/resolv.conf > $TMP_MOUNT_PATH/etc/resolv.conf
     else
         echo nameserver 8.8.8.8 > $TMP_MOUNT_PATH/etc/resolv.conf
diff --git a/lib/img-functions b/lib/img-functions
index 5be0a93fa..08a8ef426 100644
--- a/lib/img-functions
+++ b/lib/img-functions
@@ -35,7 +35,7 @@ function cleanup () {
 
 function ensure_nbd () {
     NBD=`which qemu-nbd` || true
-    if [ -z "$NBD" ];  then
+    if [ -z "$NBD" ]; then
         echo "qemu-nbd is not found in your PATH"
         echo "Please install it on your system"
         exit 1