[CRIU] [PATCH 07/12] test/zdtm.sh: use case to parse cmdline opts

Kir Kolyshkin kir at openvz.org
Fri Sep 13 14:47:04 EDT 2013


Looks cleaner this way.

Signed-off-by: Kir Kolyshkin <kir at openvz.org>
---
 test/zdtm.sh | 70 +++++++++++++++++++++++++++---------------------------------
 1 file changed, 31 insertions(+), 39 deletions(-)

diff --git a/test/zdtm.sh b/test/zdtm.sh
index a74841f..431c7df 100755
--- a/test/zdtm.sh
+++ b/test/zdtm.sh
@@ -603,81 +603,73 @@ checkout()
 cd `dirname $0` || exit 1
 
 while :; do
-	if [ "$1" = "-d" ]; then
+	case $1 in
+	  -d)
 		DUMP_ONLY=1
 		shift
-		continue
-	fi
-	if [ "$1" = "-i" ]; then
+		;;
+	  -i)
 		shift
 		ITERATIONS=$1
 		shift
-		continue
-	fi
-	if [ "$1" = "-b" ]; then
+		;;
+	  -b)
 		shift
 		checkout $1 || exit 1
 		CRIU_CPT=$TMP_TREE/criu
 		shift
-		continue
-	fi
-	if [ "$1" = "-c" ]; then
+		;;
+	  -c)
 		shift
 		checkout $1 || exit 1
 		shift
 		$TMP_TREE/test/zdtm.sh "$@"
 		exit
-	fi
-	if [ "$1" = "-p" ]; then
+		;;
+	  -p)
 		shift
 		PAGE_SERVER=1
-		continue
-	fi
-	if [ "$1" = "-C" ]; then
+		;;
+	  -C)
 		shift
 		CLEANUP=1
-		continue
-	fi
-	if [ "$1" = "-x" ]; then
+		;;
+	  -x)
 		shift
 		EXCLUDE_PATTERN=$1
 		shift
-		continue
-	fi
-	if [ "$1" = "-t" ]; then
+		;;
+	  -t)
 		shift
 		TMPFS_DUMP=dump
 		[ -d dump ] || mkdir -p $TMPFS_DUMP
 		mount -t tmpfs none $TMPFS_DUMP || exit 1
-		continue
-	fi
-	if [ "$1" = "-a" ]; then
+		;;
+	  -a)
 		shift
 		DUMP_ARCHIVE=$1
 		shift
-		continue
-	fi
-	if [ "$1" = "-s" ]; then
+		;;
+	  -s)
 		SNAPSHOT=1
 		shift
-		continue
-	fi
-	if [ "$1" = "-g" ]; then
+		;;
+	  -g)
 		COMPILE_ONLY=1
 		shift
-		continue
-	fi
-	if [ "$1" = "-n" ]; then
+		;;
+	  -n)
 		BATCH_TEST=1
 		shift
-		continue
-	fi
-	if [ "$1" = "-r" ]; then
+		;;
+	  -r)
 		SPECIFIED_NAME_USED=1
 		shift
-		continue
-	fi
-	break
+		;;
+	  *)
+		break
+		;;
+	esac
 done
 
 if [ $COMPILE_ONLY -eq 0 ]; then
-- 
1.8.1.4



More information about the CRIU mailing list