pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/bootstrap/files Add script to work around stupid 'mkdi...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/4f77e9991a94
branches:  trunk
changeset: 472803:4f77e9991a94
user:      heinz <heinz%pkgsrc.org@localhost>
date:      Mon Apr 12 14:48:58 2004 +0000

description:
Add script to work around stupid 'mkdir -p' on Unixware.
  $ mkdir -p /tmp/foo ; echo $?
  0
  $ mkdir -p /tmp/foo ; echo $?
  2
mkdir-sh calls 'mkdir' except when the target directory already exists.

diffstat:

 bootstrap/files/mkdir-sh |  44 ++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 44 insertions(+), 0 deletions(-)

diffs (48 lines):

diff -r c6b932080737 -r 4f77e9991a94 bootstrap/files/mkdir-sh
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/bootstrap/files/mkdir-sh  Mon Apr 12 14:48:58 2004 +0000
@@ -0,0 +1,44 @@
+#! /bin/sh
+# $NetBSD: mkdir-sh,v 1.1 2004/04/12 14:48:58 heinz Exp $
+#
+# workaround for the broken "mkdir -p" on Unixware
+
+MKDIRCMD=mkdir
+cmdargs="$@"
+
+# variable 'options' is unused
+for options in p m; do
+       if [ $# -lt 1 ]; then
+               ${MKDIRCMD} ${cmdargs}
+               exit $? 
+       fi
+
+       case $1 in
+               -p)     pathopt=-p;
+                       shift;;
+               -m)     modeopt="-m ${2}"
+                       shift;
+                       if [ $# -ne 0 ] ; then
+                               shift
+                       else
+                               ${MKDIRCMD} ${cmdargs}
+                               exit $?
+                       fi
+                       ;;
+       esac
+done
+
+if [ $# -gt 0 ]; then
+       while [ $# -gt 0 ]; do
+               if [ -z "${pathopt}" ]; then
+                       ${MKDIRCMD} ${modeopt} -- "$1"
+               elif [ ! -d $1 ] ; then
+                       ${MKDIRCMD} ${pathopt} ${modeopt} -- "$1"
+               else
+                       : # directory exists, nothing to do
+               fi
+               shift
+       done
+else
+       ${MKDIRCMD} ${cmdargs}
+fi



Home | Main Index | Thread Index | Old Index