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

jmpp at macports.org jmpp at macports.org
Tue Jan 15 08:14:22 PST 2008


Revision: 32968
          http://trac.macosforge.org/projects/macports/changeset/32968
Author:   jmpp at macports.org
Date:     2008-01-15 08:14:19 -0800 (Tue, 15 Jan 2008)

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

Found a clever way to abstract the command that outputs a particular MacPorts setting to the shell configuration file:
choose the form of ENV_COMMAND and ASSIGN depending on the type of shell, and of NEW_SETTING depending on the requested
shell setting. Having done that, the single "${ENV_COMMAND} ${1}${ASSIGN}${NEW_SETTING}" one liner serves us to write any
setting what-so-ever to any shell file what-so-ever (${1} expanding to the setting we're tweaking in the 'write_setting'
custom command).

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	2008-01-15 15:35:12 UTC (rev 32967)
+++ branches/release_1_6/base/portmgr/dmg/postflight	2008-01-15 16:14:19 UTC (rev 32968)
@@ -72,27 +72,16 @@
     echo -e "\n# ${OUR_STRING} adding an appropriate ${1} variable for use with MacPorts." >> ${HOME}/.${CONF_FILE}
     case ${1} in
         PATH)
-            if [ "${CONF_FILE}" == "profile" ]; then
-                echo "export PATH=${BINPATH}:${SBINPATH}:\$PATH" >> ${HOME}/.${CONF_FILE}
-            elif [ "${CONF_FILE}" == "tcshrc" ]; then
-                echo "setenv PATH ${BINPATH}:${SBINPATH}:\$PATH" >> ${HOME}/.${CONF_FILE}
-            fi
+            NEW_SETTING="${BINPATH}:${SBINPATH}:\$PATH"
             ;;
         MANPATH)
-            if [ "${CONF_FILE}" == "profile" ]; then
-                echo "export MANPATH=${MANPAGES}:\$MANPATH" >> ${HOME}/.${CONF_FILE}
-            elif [ "${CONF_FILE}" == "tcshrc" ]; then
-                echo "setenv MANPATH ${MANPAGES}:\$MANPATH" >> ${HOME}/.${CONF_FILE}
-            fi
+            NEW_SETTING="${MANPAGES}:\$MANPATH"
             ;;
         DISPLAY)
-            if [ "${CONF_FILE}" == "profile" ]; then
-                echo "export DISPLAY=:0" >> ${HOME}/.${CONF_FILE}
-            elif [ "${CONF_FILE}" == "tcshrc" ]; then
-                echo "setenv DISPLAY :0" >> ${HOME}/.${CONF_FILE}
-            fi
+            NEW_SETTING=":0"
             ;;
     esac
+    echo "${ENV_COMMAND} ${1}${ASSIGN}${NEW_SETTING}" >> ${HOME}/.${CONF_FILE}
     chown ${USER} ${HOME}/.${CONF_FILE} || echo "Warning: unable to adapt permissions on your ${HOME}/.${CONF_FILE} shell configuration file!"
     echo -e "# Finished adapting your ${1} environment variable for use with MacPorts.\n" >> ${HOME}/.${CONF_FILE}
     echo "An appropriate ${1} variable has been added to your shell environment by the MacPorts installer."
@@ -111,12 +100,16 @@
 }
 case "${USHELL}" in
     tcsh)
-        CONF_FILE=tcshrc
         LOGIN_FLAG=""
+        ENV_COMMAND="setenv"
+        ASSIGN=" "
+        CONF_FILE=tcshrc
         ;;
     bash)
-        CONF_FILE=profile
         LOGIN_FLAG="-l"
+        ENV_COMMAND="export"
+        ASSIGN="="
+        CONF_FILE=profile
         ;;
     *)
         echo "Unknown shell! Please set your MacPorts compatible environment manually."

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


More information about the macports-changes mailing list