[31912] branches/release_1_6/base/portmgr/dmg/postflight

jmpp at macports.org jmpp at macports.org
Tue Dec 11 14:03:44 PST 2007


Revision: 31912
          http://trac.macosforge.org/projects/macports/changeset/31912
Author:   jmpp at macports.org
Date:     2007-12-11 14:03:43 -0800 (Tue, 11 Dec 2007)

Log Message:
-----------

Per recommendations from Vincent Lefevre, only edit the MANPATH envvar if:

 1. it already exists (was already there);
 2. if 1), if it doesn't already contain our path (was already there);
 3. if 1), if it doesn't contain an empty path component somewhere in the middle it ('foo::bar', new check);
 4. if 1), if it doesn't contain an empty path component at the start of it (':foo', new check);
 5. if 1), if it doesn't contain an empty path component at the end of it ('foo:', new check).

In the cases of 3, 4 and 5, helper tools such as manpath(1) can still do their job and we'd proably be ruining it if we do edit the MANPATH variable.

Modified Paths:
--------------
    branches/release_1_6/base/portmgr/dmg/postflight

Modified: branches/release_1_6/base/portmgr/dmg/postflight
===================================================================
--- branches/release_1_6/base/portmgr/dmg/postflight	2007-12-11 21:07:04 UTC (rev 31911)
+++ branches/release_1_6/base/portmgr/dmg/postflight	2007-12-11 22:03:43 UTC (rev 31912)
@@ -97,8 +97,18 @@
     write_setting PATH
 fi
 
-# Adding out setting to the MANPATH variable only if it exists and, following that, if it doesn't already contain our path:
-if ! $SHELL -lc "/usr/bin/env | grep MANPATH >/dev/null 2>&1" || $SHELL -lc "/usr/bin/printenv MANPATH" | grep $MANPAGES > /dev/null 2>&1; then
+# We gather the path into a variable of our own for quicker operation:
+ORIGINAL_MANPATH=$($SHELL -lc "/usr/bin/printenv MANPATH")
+# Adding out setting to the MANPATH variable only if it exists and, following that:
+if ! $SHELL -lc "/usr/bin/env | grep MANPATH > /dev/null 2>&1" || \
+# if it doesn't already contain our path:
+  echo $ORIGINAL_MANPATH | grep $MANPAGES > /dev/null 2>&1 || \
+# if there's no empty component somewhere in the middle of it:
+  echo $ORIGINAL_MANPATH | grep :: || \
+# or at the start of it:
+  [ -z "$(echo $ORIGINAL_MANPATH | awk -F : '{print $1}')" ] || \
+# or at the end of it:
+  [ -z "$(echo $ORIGINAL_MANPATH | awk -F : '{print $NF}')" ]; then
     echo "Your shell already has the right MANPATH environment variable for use with MacPorts!"
 else
     write_setting MANPATH

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macports-changes/attachments/20071211/c197344c/attachment-0001.html


More information about the macports-changes mailing list