2 # mkinstalldirs --- make directory hierarchy
3 # Original author: Noah Friedman <friedman@prep.ai.mit.edu>
7 scriptversion=2003-09-26.19
13 Usage: mkinstalldirs [-h] [--help] [--version] [-m MODE] DIR ...
15 Create each directory DIR (with mode MODE, if specified), including all
16 leading file name components.
19 # process command line arguments
20 while test $# -gt 0 ; do
22 -h | --help | --h*) # -h for help
28 test $# -eq 0 && { echo "$usage" 1>&2; exit 1; }
33 echo "$0 $scriptversion"
36 --) # stop option processing
44 *) # first non-opt arg
52 if test -d "$file"; then
65 if mkdir -p -- . 2>/dev/null; then
69 # On NextStep and OpenStep, the `mkdir' command does not
70 # recognize any option. It will interpret all options as
71 # directories to create, and then abort because `.' already
73 test -d ./-p && rmdir ./-p
74 test -d ./-- && rmdir ./--
78 if mkdir -m "$dirmode" -p -- . 2>/dev/null; then
79 echo "mkdir -m $dirmode -p -- $*"
80 exec mkdir -m "$dirmode" -p -- "$@"
82 # Clean up after NextStep and OpenStep mkdir.
83 for d in ./-m ./-p ./-- "./$dirmode";
85 test -d $d && rmdir $d
93 set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
99 pathcomp="$pathcomp$d"
101 -*) pathcomp=./$pathcomp ;;
104 if test ! -d "$pathcomp"; then
105 echo "mkdir $pathcomp"
107 mkdir "$pathcomp" || lasterr=$?
109 if test ! -d "$pathcomp"; then
112 if test ! -z "$dirmode"; then
113 echo "chmod $dirmode $pathcomp"
115 chmod "$dirmode" "$pathcomp" || lasterr=$?
117 if test ! -z "$lasterr"; then
124 pathcomp="$pathcomp/"
133 # eval: (add-hook 'write-file-hooks 'time-stamp)
134 # time-stamp-start: "scriptversion="
135 # time-stamp-format: "%:y-%02m-%02d.%02H"
136 # time-stamp-end: "$"