#! /bin/sh
errstatus=0
dirmode=""
usage="\
Usage: mkinstalldirs [-h] [--help] [-m mode] dir ..."
while test $ case "${1}" in
-h | --help | --h* ) echo "${usage}" 1>&2; exit 0 ;;
-m ) shift
test $ dirmode="${1}"
shift ;;
-- ) shift; break ;; -* ) echo "${usage}" 1>&2; exit 1 ;; * ) break ;; esac
done
for file
do
set fnord `echo ":$file" | sed -ne 's/^:\// shift
pathcomp=
for d
do
pathcomp="$pathcomp$d"
case "$pathcomp" in
-* ) pathcomp=./$pathcomp ;;
esac
if test ! -d "$pathcomp"; then
echo "mkdir $pathcomp"
mkdir "$pathcomp" || lasterr=$?
if test ! -d "$pathcomp"; then
errstatus=$lasterr
else
if test ! -z "$dirmode"; then
echo "chmod $dirmode $pathcomp"
lasterr=""
chmod $dirmode "$pathcomp" || lasterr=$?
if test ! -z "$lasterr"; then
errstatus=$lasterr
fi
fi
fi
fi
pathcomp="$pathcomp/"
done
done
exit $errstatus