pkgsrc/bootstrap/files/mkdir-sh
heinz c0e7856048 Added definition of PATH. This fixes a silly bug of endless recursion
where "mkdir" is found in WRKDIR/.tools/bin after the tools are
available...including mkdir itself.
2005-10-09 20:12:29 +00:00

45 lines
768 B
Bash
Executable file

#! /bin/sh
# $NetBSD: mkdir-sh,v 1.2 2005/10/09 20:12:29 heinz Exp $
#
# workaround for the broken "mkdir -p" on Unixware
PATH=/usr/bin:/usr/sbin; export PATH
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