2 # mkinstalldirs --- make directory hierarchy
3 # Author: Noah Friedman <friedman@prep.ai.mit.edu>
11 Usage: mkinstalldirs [-h] [--help] [-m MODE] DIR ..."
13 # process command line arguments
14 while test $# -gt 0 ; do
16 -h | --help | --h*) # -h for help
17 echo "${usage}" 1>&2; exit 0 ;;
20 test $# -eq 0 && { echo "${usage}" 1>&2; exit 1; }
23 --) shift; break ;; # stop option processing
24 -*) echo "${usage}" 1>&2; exit 1 ;; # unknown option
25 *) break ;; # first non-opt arg
29 # no `for var; do', it breaks on Solaris 2.7 (at least).
32 if test -d "$file"; then
45 if mkdir -p -- . 2>/dev/null; then
50 if mkdir -m "$dirmode" -p -- . 2>/dev/null; then
51 echo "mkdir -m $dirmode -p -- $*"
52 exec mkdir -m "$dirmode" -p -- "$@"
58 set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
64 pathcomp="$pathcomp$d"
66 -*) pathcomp=./$pathcomp ;;
69 if test ! -d "$pathcomp"; then
70 echo "mkdir $pathcomp"
72 mkdir "$pathcomp" || lasterr=$?
74 if test ! -d "$pathcomp"; then
77 if test ! -z "$dirmode"; then
78 echo "chmod $dirmode $pathcomp"
81 chmod "$dirmode" "$pathcomp" || lasterr=$?
83 if test ! -z "$lasterr"; then