meta-ampere: fix shellcheck issues

Fix all issues from the shellcheck checked on bash shells under
meta-ampere.

Tested: Verify the following features:
1. Power control (on,off, cycle, graceful shutdown, hard reset).
2. UART switching.
3. UEFI firmware update.

Signed-off-by: Thang Q. Nguyen <thang@os.amperecomputing.com>
Change-Id: Idabf839b7521ecadb642230cc8bb3472c787002e
diff --git a/meta-ampere/meta-common/recipes-phosphor/flash/phosphor-software-manager/firmware_update.sh b/meta-ampere/meta-common/recipes-phosphor/flash/phosphor-software-manager/firmware_update.sh
index af3e2be..cc39f30f 100755
--- a/meta-ampere/meta-common/recipes-phosphor/flash/phosphor-software-manager/firmware_update.sh
+++ b/meta-ampere/meta-common/recipes-phosphor/flash/phosphor-software-manager/firmware_update.sh
@@ -21,31 +21,29 @@
 
 usage () {
 	echo "Usage:"
-	echo "	$(basename $0) <image path> "
+	echo "      $(basename "$0") <image path> "
 	echo "Where:"
 	echo "	<image path>: the path link to folder, which include image file and MANIFEST"
 	echo "Example:"
-	echo "	$(basename $0) /tmp/images/ghdh1393"
+	echo "     $(basename "$0") /tmp/images/ghdh1393"
 }
 
 
 IMG_PATH="$1"
-if [ ! -d $IMG_PATH ]; then
-	echo $IMG_PATH
+if [ ! -d "$IMG_PATH" ]; then
 	echo "The folder $IMG_PATH does not exist"
 	usage
 	exit 1
 fi
 
 MANIFEST_PATH="${IMG_PATH}/MANIFEST"
-if [ ! -f $MANIFEST_PATH ]; then
-	echo $MANIFEST_PATH
+if [ ! -f "$MANIFEST_PATH" ]; then
 	echo "The MANIFEST file $MANIFEST_PATH does not exist"
 	usage
 	exit 1
 fi
 
-EXTENDED_VERSION=$(awk '/ExtendedVersion/ {print}' ${MANIFEST_PATH} | cut -d "=" -f 2)
+EXTENDED_VERSION=$(awk '/ExtendedVersion/ {print}' "${MANIFEST_PATH}" | cut -d "=" -f 2)
 
 # If the ExtendedVersion is empty, set default to update UEFI/EDKII on primary device
 if [ -z "$EXTENDED_VERSION" ]
@@ -56,28 +54,28 @@
 # Assign the command based on the ExtendedVersion
 case ${EXTENDED_VERSION} in
 	"primary")
-		export IMAGE=$(find ${IMG_PATH} -type f \( -name "*.img" -o -name "*.bin" -o -name "*.rom" \))
-		export CMD='/usr/sbin/ampere_flash_bios.sh $IMAGE 1'
+		IMAGE=$(find "${IMG_PATH}" -type f \( -name "*.img" -o -name "*.bin" -o -name "*.rom" \))
+		CMD="/usr/sbin/ampere_flash_bios.sh $IMAGE 1"
 		;;
 
 	"secondary")
-		export IMAGE=$(find ${IMG_PATH} -type f \( -name "*.img" -o -name "*.bin" -o -name "*.rom" \))
-		export CMD='/usr/sbin/ampere_flash_bios.sh $IMAGE 2'
+		IMAGE=$(find "${IMG_PATH}" -type f \( -name "*.img" -o -name "*.bin" -o -name "*.rom" \))
+		CMD="/usr/sbin/ampere_flash_bios.sh $IMAGE 2"
 		;;
 
 	"scp-primary")
-		export IMAGE=$(find ${IMG_PATH} -type f \( -name "*.img" -o -name "*.slim" -o -name "*.rom" \))
-		export CMD='/usr/sbin/ampere_firmware_upgrade.sh smpmpro $IMAGE 1'
+		IMAGE=$(find "${IMG_PATH}" -type f \( -name "*.img" -o -name "*.slim" -o -name "*.rom" \))
+		CMD="/usr/sbin/ampere_firmware_upgrade.sh smpmpro $IMAGE 1"
 		;;
 
 	"scp-secondary")
-		export IMAGE=$(find ${IMG_PATH} -type f \( -name "*.img" -o -name "*.slim" -o -name "*.rom" \))
-		export CMD='/usr/sbin/ampere_firmware_upgrade.sh smpmpro $IMAGE 2'
+		IMAGE=$(find "${IMG_PATH}" -type f \( -name "*.img" -o -name "*.slim" -o -name "*.rom" \))
+		CMD="/usr/sbin/ampere_firmware_upgrade.sh smpmpro $IMAGE 2"
 		;;
 
 	"fru")
-		export IMAGE=$(find ${IMG_PATH} -type f \( -name "*.bin" \))
-		export CMD='/usr/sbin/ampere_firmware_upgrade.sh fru $IMAGE'
+		IMAGE=$(find "${IMG_PATH}" -type f \( -name "*.bin" \))
+		CMD="/usr/sbin/ampere_firmware_upgrade.sh fru $IMAGE"
 		;;
 
 	*)
@@ -91,11 +89,10 @@
 then
 	echo "ERROR: The image file: No such file or directory"
 	exit 1
-else
-	eval $CMD
 fi
 
-if [[ $? -ne 0 ]]; then
+if ! eval "$CMD";
+then
 	echo "ERROR: The firmware update not successfull"
 	exit 1
 fi