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
22 test $# -eq 0 && { echo "$usage" 1>&2; exit 1; }
26 --) # stop option processing
34 *) # first non-opt arg
42 if test -d "$file"; then
55 if mkdir
-p -- .
2>/dev
/null
; then
61 if mkdir
-m "$dirmode" -p -- .
2>/dev
/null
; then
62 echo "mkdir -m $dirmode -p -- $*"
63 exec mkdir
-m "$dirmode" -p -- "$@"
70 set fnord
`echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
76 pathcomp
="$pathcomp$d"
78 -*) pathcomp
=.
/$pathcomp ;;
81 if test ! -d "$pathcomp"; then
82 echo "mkdir $pathcomp"
84 mkdir
"$pathcomp" || lasterr
=$?
86 if test ! -d "$pathcomp"; then
89 if test ! -z "$dirmode"; then
90 echo "chmod $dirmode $pathcomp"
92 chmod "$dirmode" "$pathcomp" || lasterr
=$?
94 if test ! -z "$lasterr"; then
101 pathcomp
="$pathcomp/"
111 # mkinstalldirs ends here