2 # mkinstalldirs --- make directory hierarchy
3 # Author: Noah Friedman <friedman@prep.ai.mit.edu>
7 # $Id: mkinstalldirs,v 1.8 2001/09/29 05:50:16 eggert Exp $
13 Usage: mkinstalldirs [-h] [--help] [-m mode] dir ..."
15 # process command line arguments
16 while test $# -gt 0 ; do
18 -h | --help | --h* ) # -h for help
19 echo "${usage}" 1>&2; exit 0 ;;
22 test $# -eq 0 && { echo "${usage}" 1>&2; exit 1; }
25 -- ) shift; break ;; # stop option processing
26 -* ) echo "${usage}" 1>&2; exit 1 ;; # unknown option
27 * ) break ;; # first non-opt arg
37 if mkdir -p -- . 2>/dev/null; then
42 if mkdir -m "$dirmode" -p -- . 2>/dev/null; then
43 echo "mkdir -m $dirmode -p -- $*"
44 exec mkdir -m "$dirmode" -p -- "$@"
50 set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
56 pathcomp="$pathcomp$d"
58 -* ) pathcomp=./$pathcomp ;;
61 if test ! -d "$pathcomp"; then
62 echo "mkdir $pathcomp"
64 mkdir "$pathcomp" || lasterr=$?
66 if test ! -d "$pathcomp"; then
69 if test ! -z "$dirmode"; then
70 echo "chmod $dirmode $pathcomp"
73 chmod "$dirmode" "$pathcomp" || lasterr=$?
75 if test ! -z "$lasterr"; then
92 # mkinstalldirs ends here