Blame SOURCES/0010-virt-what.in-make-option-processing-portable.patch

b6cf65
From aec669f7b9e4a172c57978597916f8bd97bf26de Mon Sep 17 00:00:00 2001
b6cf65
From: Assaf Gordon <assafgordon@gmail.com>
b6cf65
Date: Mon, 15 Sep 2014 19:34:06 +0000
b6cf65
Subject: [PATCH 10/16] virt-what.in: make option processing portable
b6cf65
b6cf65
Replace linux-specific 'getopt' usage with manual option parsing.
b6cf65
Because the used option are version simple (help/version) and the only
b6cf65
additional option is undocumented (--test-root), it's easy remove the
b6cf65
'getopt' usage, and make this script portable to BSD systems.
b6cf65
---
b6cf65
 virt-what.in | 17 +++++++----------
b6cf65
 1 file changed, 7 insertions(+), 10 deletions(-)
b6cf65
b6cf65
diff --git a/virt-what.in b/virt-what.in
b6cf65
index 6e9aef1..f2c0b90 100644
b6cf65
--- a/virt-what.in
b6cf65
+++ b/virt-what.in
b6cf65
@@ -51,24 +51,21 @@ usage() {
b6cf65
 }
b6cf65
 
b6cf65
 # Handle the command line arguments, if any.
b6cf65
-
b6cf65
-TEMP=$(getopt -o v --long help --long version --long test-root: -n 'virt-what' -- "$@")
b6cf65
-if [ $? != 0 ]; then exit 1; fi
b6cf65
-eval set -- "$TEMP"
b6cf65
-
b6cf65
-while true; do
b6cf65
+while test $# -gt 0; do
b6cf65
     case "$1" in
b6cf65
 	--help) usage ;;
b6cf65
-        --test-root)
b6cf65
+        --test-root=*)
b6cf65
             # Deliberately undocumented: used for 'make check'.
b6cf65
-            root="$2"
b6cf65
-            shift 2
b6cf65
+            root=$(echo "$1" | sed 's/.*=//')
b6cf65
+            shift 1
b6cf65
+            test -z "$root" && fail "--test-root option requires a value"
b6cf65
             ;;
b6cf65
 	-v|--version) echo "$VERSION"; exit 0 ;;
b6cf65
 	--) shift; break ;;
b6cf65
-	*) fail "internal error ($1)" ;;
b6cf65
+	*) fail "unrecognized option '$1'";;
b6cf65
     esac
b6cf65
 done
b6cf65
+test $# -gt 0 && fail "extra operand '$1'"
b6cf65
 
b6cf65
 # Add /sbin and /usr/sbin to the path so we can find system
b6cf65
 # binaries like dmidecode.
b6cf65
-- 
b6cf65
2.3.1
b6cf65