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-jade/recipes-ampere/flash/ampere-flash-utils/ampere_flash_bios.sh b/meta-ampere/meta-jade/recipes-ampere/flash/ampere-flash-utils/ampere_flash_bios.sh
index 7a9ace3..b7f4bc5 100755
--- a/meta-ampere/meta-jade/recipes-ampere/flash/ampere-flash-utils/ampere_flash_bios.sh
+++ b/meta-ampere/meta-jade/recipes-ampere/flash/ampere-flash-utils/ampere_flash_bios.sh
@@ -18,7 +18,7 @@
         OFFSET=$1
 
 	# Check the PNOR partition available
-	HOST_MTD=$(cat /proc/mtd | grep "pnor" | sed -n 's/^\(.*\):.*/\1/p')
+	HOST_MTD=$(< /proc/mtd grep "pnor" | sed -n 's/^\(.*\):.*/\1/p')
 	if [ -z "$HOST_MTD" ];
 	then
 		# If the PNOR partition is not available, then bind again driver
@@ -26,7 +26,7 @@
 		echo 1e630000.spi > /sys/bus/platform/drivers/aspeed-smc/bind
 		sleep 2
 
-		HOST_MTD=$(cat /proc/mtd | grep "pnor" | sed -n 's/^\(.*\):.*/\1/p')
+		HOST_MTD=$(< /proc/mtd grep "pnor" | sed -n 's/^\(.*\):.*/\1/p')
 		if [ -z "$HOST_MTD" ];
 		then
 			echo "Fail to probe Host SPI-NOR device"
@@ -35,18 +35,17 @@
 	fi
 
 	echo "--- Flashing firmware to @/dev/$HOST_MTD offset=$OFFSET"
-	flashcp -v $IMAGE /dev/$HOST_MTD $OFFSET
+	flashcp -v "$IMAGE" /dev/"$HOST_MTD" "$OFFSET"
 }
 
 
 if [ $# -eq 0 ]; then
-	echo "Usage: $(basename $0) <BIOS image file>"
+	echo "Usage: $(basename "$0") <BIOS image file>"
 	exit 0
 fi
 
 IMAGE="$1"
-if [ ! -f $IMAGE ]; then
-	echo $IMAGE
+if [ ! -f "$IMAGE" ]; then
 	echo "The image file $IMAGE does not exist"
 	exit 1
 fi
@@ -70,9 +69,7 @@
 
 # Switch the host SPI bus to BMC"
 echo "--- Switch the host SPI bus to BMC."
-gpioset 0 226=0
-
-if [[ $? -ne 0 ]]; then
+if ! gpioset 0 226=0; then
 	echo "ERROR: Switch the host SPI bus to BMC. Please check gpio state"
 	exit 1
 fi
@@ -82,9 +79,7 @@
 
 # Switch the host SPI bus to HOST."
 echo "--- Switch the host SPI bus to HOST."
-gpioset 0 226=1
-
-if [[ $? -ne 0 ]]; then
+if ! gpioset 0 226=1; then
 	echo "ERROR: Switch the host SPI bus to HOST. Please check gpio state"
 	exit 1
 fi