2 # mkinstalldirs --- make directory hierarchy
4 scriptversion
=2003-11-08.23
6 # Original author: Noah Friedman <friedman@prep.ai.mit.edu>
10 # This file is maintained in Automake, please report
11 # bugs to <bug-automake@gnu.org> or send patches to
12 # <automake-patches@gnu.org>.
18 Usage: mkinstalldirs [-h] [--help] [--version] [-m MODE] DIR ...
20 Create each directory DIR (with mode MODE, if specified), including all
21 leading file name components.
23 Report bugs to <bug-automake@gnu.org>."
25 # process command line arguments
26 while test $# -gt 0 ; do
28 -h |
--help |
--h*) # -h for help
34 test $# -eq 0 && { echo "$usage" 1>&2; exit 1; }
39 echo "$0 $scriptversion"
42 --) # stop option processing
50 *) # first non-opt arg
58 if test -d "$file"; then
71 if mkdir
-p -- .
2>/dev
/null
; then
75 # On NextStep and OpenStep, the `mkdir' command does not
76 # recognize any option. It will interpret all options as
77 # directories to create, and then abort because `.' already
79 test -d .
/-p && rmdir .
/-p
80 test -d .
/-- && rmdir .
/--
84 if mkdir
-m "$dirmode" -p -- .
2>/dev
/null
; then
85 echo "mkdir -m $dirmode -p -- $*"
86 exec mkdir
-m "$dirmode" -p -- "$@"
88 # Clean up after NextStep and OpenStep mkdir.
89 for d
in .
/-m .
/-p .
/-- "./$dirmode";
91 test -d $d && rmdir $d
99 set fnord
`echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
105 pathcomp
="$pathcomp$d"
107 -*) pathcomp
=.
/$pathcomp ;;
110 if test ! -d "$pathcomp"; then
111 echo "mkdir $pathcomp"
113 mkdir
"$pathcomp" || lasterr
=$?
115 if test ! -d "$pathcomp"; then
118 if test ! -z "$dirmode"; then
119 echo "chmod $dirmode $pathcomp"
121 chmod "$dirmode" "$pathcomp" || lasterr
=$?
123 if test ! -z "$lasterr"; then
130 pathcomp
="$pathcomp/"
139 # eval: (add-hook 'write-file-hooks 'time-stamp)
140 # time-stamp-start: "scriptversion="
141 # time-stamp-format: "%:y-%02m-%02d.%02H"
142 # time-stamp-end: "$"