diff --git a/src/configure b/src/configure
index c264578f55c6c76a1bc018d5ab7402299d861411..400aa4c256e952295125300b4be6137d2410c2b7 100755
--- a/src/configure
+++ b/src/configure
@@ -642,11 +642,11 @@ starts 'checking host system type...'
 EOT
 	TEMPLATE=generic
 	GUESS=`grep "$host_os" template/.similar 2>/dev/null`
-	if test $GUESS
-	then	host_os_no_ver=`grep "$host_os" | sed 's/0-9.*$//'`
+	if test ! "$GUESS"
+	then    host_os_no_ver=`echo "$host_os" | sed 's/[0-9.]*$//'`
 		GUESS=`grep "$host_os_no_ver" template/.similar 2>/dev/null`
 	fi
-	if test $GUESS
+	if test "$GUESS"
 	then
 		TEMPLATE=`echo $GUESS | sed 's/.*=//'`
 	fi
diff --git a/src/configure.in b/src/configure.in
index 989123ec8b73dc43df59ec52c5ed11ac21450c77..2c60ff92054e7d825bce07347a189017e8e764fc 100644
--- a/src/configure.in
+++ b/src/configure.in
@@ -80,11 +80,11 @@ starts 'checking host system type...'
 EOT
 	TEMPLATE=generic
 	GUESS=`grep "$host_os" template/.similar 2>/dev/null`
-	if test $GUESS
-	then	host_os_no_ver=`grep "$host_os" | sed 's/[0-9.]*$//'`
+	if test ! "$GUESS"
+	then	host_os_no_ver=`echo "$host_os" | sed 's/[0-9.]*$//'`
 		GUESS=`grep "$host_os_no_ver" template/.similar 2>/dev/null`
 	fi
-	if test $GUESS
+	if test "$GUESS"
 	then
 		TEMPLATE=`echo $GUESS | sed 's/.*=//'`
 	fi