[CalendarServer-changes] [13737] CalendarServer/trunk/bin

source_changes at macosforge.org source_changes at macosforge.org
Wed Jul 9 10:01:13 PDT 2014


Revision: 13737
          http://trac.calendarserver.org//changeset/13737
Author:   wsanchez at apple.com
Date:     2014-07-09 10:01:13 -0700 (Wed, 09 Jul 2014)
Log Message:
-----------
Make more happy on POSIX shell

Modified Paths:
--------------
    CalendarServer/trunk/bin/_build.sh
    CalendarServer/trunk/bin/_py.sh

Modified: CalendarServer/trunk/bin/_build.sh
===================================================================
--- CalendarServer/trunk/bin/_build.sh	2014-07-09 00:54:03 UTC (rev 13736)
+++ CalendarServer/trunk/bin/_build.sh	2014-07-09 17:01:13 UTC (rev 13737)
@@ -121,34 +121,34 @@
 
   hash="";
 
-  if type -ft openssl > /dev/null; then
+  if find_cmd openssl > /dev/null; then
     if [ -z "${hash}" ]; then hash="md5"; fi;
-    md5 () { "$(type -p openssl)" dgst -md5 "$@"; }
-  elif type -ft md5 > /dev/null; then
+    md5 () { "$(find_cmd openssl)" dgst -md5 "$@"; }
+  elif find_cmd md5 > /dev/null; then
     if [ -z "${hash}" ]; then hash="md5"; fi;
-    md5 () { "$(type -p md5)" "$@"; }
-  elif type -ft md5sum > /dev/null; then
+    md5 () { "$(find_cmd md5)" "$@"; }
+  elif find_cmd md5sum > /dev/null; then
     if [ -z "${hash}" ]; then hash="md5"; fi;
-    md5 () { "$(type -p md5sum)" "$@"; }
+    md5 () { "$(find_cmd md5sum)" "$@"; }
   fi;
 
-  if type -ft sha1sum > /dev/null; then
+  if find_cmd sha1sum > /dev/null; then
     if [ -z "${hash}" ]; then hash="sha1sum"; fi;
-    sha1 () { "$(type -p sha1sum)" "$@"; }
+    sha1 () { "$(find_cmd sha1sum)" "$@"; }
   fi;
-  if type -ft shasum > /dev/null; then
+  if find_cmd shasum > /dev/null; then
     if [ -z "${hash}" ]; then hash="sha1"; fi;
-    sha1 () { "$(type -p shasum)" "$@"; }
+    sha1 () { "$(find_cmd shasum)" "$@"; }
   fi;
 
   if [ "${hash}" = "sha1" ]; then
     hash () { sha1 "$@"; }
   elif [ "${hash}" = "md5" ]; then
     hash () { md5 "$@"; }
-  elif type -t cksum > /dev/null; then
+  elif find_cmd cksum > /dev/null; then
     hash="hash";
     hash () { cksum "$@" | cut -f 1 -d " "; }
-  elif type -t sum > /dev/null; then
+  elif find_cmd sum > /dev/null; then
     hash="hash";
     hash () { sum "$@" | cut -f 1 -d " "; }
   else

Modified: CalendarServer/trunk/bin/_py.sh
===================================================================
--- CalendarServer/trunk/bin/_py.sh	2014-07-09 00:54:03 UTC (rev 13736)
+++ CalendarServer/trunk/bin/_py.sh	2014-07-09 17:01:13 UTC (rev 13737)
@@ -15,6 +15,18 @@
 # limitations under the License.
 ##
 
+find_cmd () {
+  local cmd="$1"; shift;
+
+  local path="$(type "${cmd}" 2>/dev/null | sed "s|^${cmd} is \(a tracked alias for \)\{0,1\}||")";
+
+  if [ -z "${cmd}" ]; then
+    return 1;
+  fi;
+
+  echo "${path}";
+}
+
 # Echo the major.minor version of the given Python interpreter.
 
 py_version () {
@@ -38,7 +50,7 @@
   fi;
 
   local py_version="$(py_version "${python}")";
-  if [ "${py_version/./}" -lt "25" ]; then
+  if [ "$(echo "${py_version}" | sed 's|\.||')" -lt "25" ]; then
     return 1;
   fi;
   return 0;
@@ -72,7 +84,7 @@
       "/sw/bin/python${v}"                                              \
       ;
     do
-      if p="$(type -p "${p}")"; then
+      if p="$(find_cmd "${p}")"; then
         if try_python "${p}"; then
           echo "${p}";
           return 0;
@@ -148,7 +160,7 @@
   # the part of the PostgreSQL build process which builds pl_python.  Note that
   # detect_python_version, above, already honors $PYTHON, so if this is already
   # set it won't be stomped on, it will just be re-set to the same value.
-  export PYTHON="$(type -p ${bootstrap_python})";
+  export PYTHON="$(find_cmd ${bootstrap_python})";
 
   if [ -z "${bootstrap_python:-}" ]; then
     echo "No suitable python found. Python 2.6 or 2.7 is required.";
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140709/a71f4e40/attachment.html>


More information about the calendarserver-changes mailing list