2 # mkinstalldirs --- make directory hierarchy
3 # Author: Noah Friedman <friedman@prep.ai.mit.edu>
7 # $Id: mkinstalldirs 36980 2004-12-03 01:08:33Z benm $
13 Usage: mkinstalldirs [-h] [--help] [-m mode] dir ..."
15 # process command line arguments
16 while test $# -gt 0 ; do
18 -h |
--help |
--h* ) # -h for help
19 echo "${usage}" 1>&2; exit 0 ;;
22 test $# -eq 0 && { echo "${usage}" 1>&2; exit 1; }
25 -- ) shift; break ;; # stop option processing
26 -* ) echo "${usage}" 1>&2; exit 1 ;; # unknown option
27 * ) break ;; # first non-opt arg
33 if test -d "$file"; then
46 if mkdir
-p -- .
2>/dev
/null
; then
51 if mkdir
-m "$dirmode" -p -- .
2>/dev
/null
; then
52 echo "mkdir -m $dirmode -p -- $*"
53 exec mkdir
-m "$dirmode" -p -- "$@"
59 set fnord
`echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
65 pathcomp
="$pathcomp$d"
67 -* ) pathcomp
=.
/$pathcomp ;;
70 if test ! -d "$pathcomp"; then
71 echo "mkdir $pathcomp"
73 mkdir
"$pathcomp" || lasterr
=$?
75 if test ! -d "$pathcomp"; then
78 if test ! -z "$dirmode"; then
79 echo "chmod $dirmode $pathcomp"
82 chmod "$dirmode" "$pathcomp" || lasterr
=$?
84 if test ! -z "$lasterr"; then
101 # mkinstalldirs ends here