2 # mkinstalldirs --- make directory hierarchy
3 # Author: Noah Friedman <friedman@prep.ai.mit.edu>
7 # $Id: mkinstalldirs,v 1.4 2005-04-01 13:48:30 gja-guest Exp $
14 chmodprog
="${CHMODPROG-chmod}"
15 chownprog
="${CHOWNPROG-chown}"
16 chgrpprog
="${CHOWNPROG-chgrp}"
19 Usage: mkinstalldirs [-h] [--help] [-m mode] [-o owner] [-g group] dir ..."
21 # process command line arguments
22 while test $# -gt 0 ; do
24 -h |
--help |
--h* ) # -h for help
25 echo "${usage}" 1>&2; exit 0 ;;
28 test $# -eq 0 && { echo "${usage}" 1>&2; exit 1; }
33 test $# -eq 0 && { echo "${usage}" 1>&2; exit 1; }
38 test $# -eq 0 && { echo "${usage}" 1>&2; exit 1; }
41 -- ) shift; break ;; # stop option processing
42 -* ) echo "${usage}" 1>&2; exit 1 ;; # unknown option
43 * ) break ;; # first non-opt arg
49 set fnord
`echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
55 pathcomp
="$pathcomp$d"
57 -* ) pathcomp
=.
/$pathcomp ;;
60 if test ! -d "$pathcomp" -a ! -d "$pathcomp/"; then
61 echo "mkdir $pathcomp"
63 mkdir
"$pathcomp" || lasterr
=$?
65 if test ! -d "$pathcomp" -a ! -d "$pathcomp/"; then
68 if test ! -z "$dirmode"; then
69 echo "$chmodprog $dirmode $pathcomp"
72 $chmodprog $dirmode "$pathcomp" || lasterr
=$?
74 if test ! -z "$lasterr"; then
78 if test ! -z "$owner"; then
79 echo "$chownprog $owner $pathcomp"
82 $chownprog $owner "$pathcomp" || lasterr
=$?
84 if test ! -z "$lasterr"; then
88 if test ! -z "$group"; then
89 echo "$chgrpprog $group $pathcomp"
92 $chgrpprog $group "$pathcomp" || lasterr
=$?
94 if test ! -z "$lasterr"; then
101 pathcomp
="$pathcomp/"