From 72b067b2c212eac0ed7a14f6ede8a5537e042418 Mon Sep 17 00:00:00 2001
From: chebrard <chebrard@localhost>
Date: Tue, 04 Nov 2008 19:58:07 +0000
Subject: [PATCH] Fix 3548: perf regression in OpenDS between rev 4539 and rev 4548

---
 opends/resource/bin/_script-util.sh |   58 +++++++++++++++++++++++++++++++++-------------------------
 1 files changed, 33 insertions(+), 25 deletions(-)

diff --git a/opends/resource/bin/_script-util.sh b/opends/resource/bin/_script-util.sh
index c77e45c..7a3d522 100644
--- a/opends/resource/bin/_script-util.sh
+++ b/opends/resource/bin/_script-util.sh
@@ -160,6 +160,19 @@
   export CLASSPATH
 }
 
+isVersionOrHelp() {
+  for opt in `echo $*`
+  do
+	if [ $opt = "-V" ] || [ $opt = "--version" ] || 
+		[ $opt = "-H" ] || [ $opt = "--help" ] ||
+                [ $opt = "-F" ] || [ $opt = "--fullversion" ]
+	then
+		return 0
+	fi
+  done
+  return 1 
+}
+
 if test "${INSTALL_ROOT}" = ""
 then
   # Capture the current working directory so that we can change to it later.
@@ -175,18 +188,6 @@
 
 if test "${INSTANCE_ROOT}" = ""
 then
-  for opt in `echo $*`
-  do
-	if [ $opt = "-V" ] || [ $opt = "--version" ] || 
-		[ $opt = "-H" ] || [ $opt = "--help" ] 
-	then
-		INSTANCE_ROOT="not_needed"
-	fi
-  done
-fi
-
-if test "${INSTANCE_ROOT}" = ""
-then
   if [ -f ${INSTALL_ROOT}/configure ]
   then
     if [ -f /etc/opt/opends/instance.loc ]
@@ -200,8 +201,12 @@
     else
       if [ "${SCRIPT_NAME}" != "configure" ]
       then
-        echo "No instance found. Run ${INSTALL_ROOT}/configure to create it."
-        exit 1
+        isVersionOrHelp $*
+        if [ $? -eq 1 ]
+        then
+          echo "No instance found. Run ${INSTALL_ROOT}/configure to create it."
+          exit 1
+        fi
       fi
     fi
   else
@@ -262,17 +267,20 @@
 
 if [ "${SCRIPT_NAME}" != "configure" ]
 then 
-  NO_CHECK=0
-  for opt in `echo $*`
-  do
-    # No check for --version or --help option
-	if [ $opt = "-V" ] || [ $opt = "--version" ] || 
-		[ $opt = "-H" ] || [ $opt = "--help" ]  ||
-		[ $opt = "-F" ] || [ $opt = "--fullversion" ] 
-	then
-		NO_CHECK=1
-	fi
-  done
+  # Perform check unless it is specified not to do it
+  if [ -z "$NO_CHECK" ]
+  then
+     NO_CHECK=0
+  fi
+  if [ ${NO_CHECK} -eq 0 ]
+  then
+      # No check for --version or --help option
+      isVersionOrHelp $*
+      if [ $? -eq 0 ]
+      then
+        NO_CHECK=1
+      fi
+  fi
   if [ ${NO_CHECK} -eq 0 ]
   then
     set_classpath

--
Gitblit v1.10.0