patch for 'select.sh'

Michael Dickens michaelld at macports.org
Wed Jul 7 12:18:17 PDT 2010


Here's a simple patch for 'select.sh' that adds in a check to make sure
the target's directory exists -- and if not then creates it.  I've
tested this patch locally and it works correctly, both when the target
directory already exists and when it does not.  A similar check could be
made on the 'rm' side to remove cleared directories, but that can come
later.  I came upon this issue working on ticket #25459, and I think
this is the correct solution and not to force keeping of directories
from inside the Portfile.  I do not know who's in charge of this file,
nor how to commit a patch to it beyond creating a patchfile. - MLD

========================
--- select.sh.orig      2010-07-07 09:49:45.000000000 -0600
+++ select.sh   2010-07-07 12:33:46.000000000 -0600
@@ -101,6 +101,17 @@
             rm -f ${2}
         fi
     elif [ "ln" == "${1}" ]; then
+        # make sure the target directory exists:
+        # retrieve the directory path from ${3}
+        dir_path=`dirname ${3}`
+        if [ ! -e ${dir_path} ]; then
+            if [ 1 == "${noexec}" ]; then
+                echo "mkdir -p ${dir_path}"
+            else
+                mkdir -p ${dir_path}
+            fi
+        fi
+        # now that the target directory exists, create the link
         if [ 1 == "${noexec}" ]; then
             echo "ln -snf ${2} ${3}"
         else


More information about the macports-dev mailing list