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
31 if test -d "$file"; then
44 if mkdir -p -- . 2>/dev/null; then
49 # We cannot trust mkdir to set the proper permissions on
50 # parent directories. So create them manually.
68 pathcomp="$pathcomp$d"
69 if test ! -d "$pathcomp"; then
70 echo "mkdir $pathcomp"
71 mkdir "$pathcomp" || lasterr=$?
73 if test ! -d "$pathcomp"; then
76 elif test -n "$dirmode"; then
77 echo "chmod $dirmode $pathcomp"
79 chmod "$dirmode" "$pathcomp" || lasterr=$?
80 if test -n "$lasterr"; then
97 # mkinstalldirs ends here