[Skiboot] [PATCH 1/2] external/boot-tests: Fix logging functions in boot_test.sh

Andrew Donnellan andrew.donnellan at au1.ibm.com
Thu Jul 30 15:59:49 AEST 2015


Fix the error() and msg() functions in boot_test.sh so they don't cause a
shell error when called before $target is set (i.e. before parameter
parsing).

Change error() to allow the use of multiple arguments in the message, in
line with msg(). Use $* rather than $@ as it's very slightly more correct.

Signed-off-by: Andrew Donnellan <andrew.donnellan at au1.ibm.com>
---
 external/boot-tests/boot_test.sh | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/external/boot-tests/boot_test.sh b/external/boot-tests/boot_test.sh
index b7f14e4..303f78e 100755
--- a/external/boot-tests/boot_test.sh
+++ b/external/boot-tests/boot_test.sh
@@ -5,6 +5,7 @@
 set -uo pipefail
 
 V=0;
+target=""
 
 if [ -f ~/.skiboot_boot_tests ]; then
 	source ~/.skiboot_boot_tests
@@ -12,14 +13,23 @@ fi
 
 # Utility functions
 function error {
-	unset SSHPASS;
-	echo "$target: $1" >&2;
-	exit 1;
+	unset SSHPASS
+	if [ ! -z "$target" ]; then
+		echo "$target: $*" >&2
+	else
+		echo "$0: $*" >&2
+	fi
+	
+	exit 1
 }
 
 function msg {
-	if [ $V -ne 0 ] ; then
-		echo "$target: $@";
+	if [ $V -ne 0 ]; then
+		if [ ! -z "$target" ]; then
+			echo "$target: $*"
+		else
+			echo "$0: $*"
+		fi
 	fi
 }
 
-- 
2.1.4



More information about the Skiboot mailing list