From 5a726240a2e3fc25d7d324ff483567ec4b1b06ee Mon Sep 17 00:00:00 2001
From: lutoff <lutoff@localhost>
Date: Mon, 23 Mar 2009 17:52:47 +0000
Subject: [PATCH] Fix for issue #3626 (Occurrences of grep, cat,... commands should be replaced with sh built-in commands) Replace occurrences of 'cat' and 'grep' by shell builtin command.

---
 opends/resource/bin/stop-ds                                 |    3 ++-
 opends/resource/bin/_script-util.sh                         |   19 ++++++++++++-------
 opends/src/quicksetup/org/opends/quicksetup/util/Utils.java |    4 ++--
 3 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/opends/resource/bin/_script-util.sh b/opends/resource/bin/_script-util.sh
index b7bb925..b10b277 100644
--- a/opends/resource/bin/_script-util.sh
+++ b/opends/resource/bin/_script-util.sh
@@ -205,7 +205,7 @@
           exit 0
 	fi
       fi
-      INSTANCE_ROOT=`cat /etc/opends/instance.loc`
+      read INSTANCE_ROOT <  /etc/opends/instance.loc
     else
       if [ "${SCRIPT_NAME}" != "configure" ]
       then
@@ -220,12 +220,17 @@
   else
     if [ -f ${INSTALL_ROOT}/instance.loc ]
     then
-      if cat ${INSTALL_ROOT}/instance.loc | grep '^/' > /dev/null
-      then
-         INSTANCE_ROOT=`cat ${INSTALL_ROOT}/instance.loc`
-      else
-         INSTANCE_ROOT=${INSTALL_ROOT}/`cat ${INSTALL_ROOT}/instance.loc`
-      fi
+      read location < ${INSTALL_ROOT}/instance.loc
+      case `echo ${location}` in
+           /*)
+              INSTANCE_ROOT=${location}
+              break
+              ;;
+           *)
+              INSTANCE_ROOT=${INSTALL_ROOT}/${location}
+              break
+              ;;
+      esac
     else
          INSTANCE_ROOT=${INSTALL_ROOT}
     fi
diff --git a/opends/resource/bin/stop-ds b/opends/resource/bin/stop-ds
index f22ffe0..09e241d 100755
--- a/opends/resource/bin/stop-ds
+++ b/opends/resource/bin/stop-ds
@@ -159,7 +159,8 @@
 then
   if test -f "${INSTANCE_ROOT}/logs/server.pid"
   then
-    kill `cat "${INSTANCE_ROOT}/logs/server.pid"`
+    read PID < "${INSTANCE_ROOT}/logs/server.pid"
+    kill ${PID}
     EXIT_CODE=${?}
     if test ${EXIT_CODE} -eq 0
     then
diff --git a/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java b/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java
index 2dcbf3f..63faa3b 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java
@@ -22,7 +22,7 @@
  * CDDL HEADER END
  *
  *
- *      Copyright 2006-2008 Sun Microsystems, Inc.
+ *      Copyright 2006-2009 Sun Microsystems, Inc.
  */
 package org.opends.quicksetup.util;
 
@@ -1214,7 +1214,7 @@
     try
     {
       line = reader.readLine();
-      File instanceLoc =  new File (line);
+      File instanceLoc =  new File (line.trim());
       if (instanceLoc.isAbsolute())
       {
         return instanceLoc.getAbsolutePath();

--
Gitblit v1.10.0