build-scripts/mkinstalldirs
changeset 1361 19418e4422cb
child 12335 5e68900d2232
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/build-scripts/mkinstalldirs	Thu Feb 16 10:11:48 2006 +0000
     1.3 @@ -0,0 +1,99 @@
     1.4 +#! /bin/sh
     1.5 +# mkinstalldirs --- make directory hierarchy
     1.6 +# Author: Noah Friedman <friedman@prep.ai.mit.edu>
     1.7 +# Created: 1993-05-16
     1.8 +# Public domain
     1.9 +
    1.10 +errstatus=0
    1.11 +dirmode=""
    1.12 +
    1.13 +usage="\
    1.14 +Usage: mkinstalldirs [-h] [--help] [-m mode] dir ..."
    1.15 +
    1.16 +# process command line arguments
    1.17 +while test $# -gt 0 ; do
    1.18 +   case "${1}" in
    1.19 +     -h | --help | --h* )			# -h for help
    1.20 +	echo "${usage}" 1>&2; exit 0 ;;
    1.21 +     -m )					# -m PERM arg
    1.22 +	shift
    1.23 +	test $# -eq 0 && { echo "${usage}" 1>&2; exit 1; }
    1.24 +	dirmode="${1}"
    1.25 +	shift ;;
    1.26 +     -- ) shift; break ;;			# stop option processing
    1.27 +     -* ) echo "${usage}" 1>&2; exit 1 ;;	# unknown option
    1.28 +     * )  break ;;				# first non-opt arg
    1.29 +   esac
    1.30 +done
    1.31 +
    1.32 +for file
    1.33 +do
    1.34 +  if test -d "$file"; then
    1.35 +    shift
    1.36 +  else
    1.37 +    break
    1.38 +  fi
    1.39 +done
    1.40 +
    1.41 +case $# in
    1.42 +0) exit 0 ;;
    1.43 +esac
    1.44 +
    1.45 +case $dirmode in
    1.46 +'')
    1.47 +  if mkdir -p -- . 2>/dev/null; then
    1.48 +    echo "mkdir -p -- $*"
    1.49 +    exec mkdir -p -- "$@"
    1.50 +  fi ;;
    1.51 +*)
    1.52 +  if mkdir -m "$dirmode" -p -- . 2>/dev/null; then
    1.53 +    echo "mkdir -m $dirmode -p -- $*"
    1.54 +    exec mkdir -m "$dirmode" -p -- "$@"
    1.55 +  fi ;;
    1.56 +esac
    1.57 +
    1.58 +for file
    1.59 +do
    1.60 +   set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
    1.61 +   shift
    1.62 +
    1.63 +   pathcomp=
    1.64 +   for d
    1.65 +   do
    1.66 +     pathcomp="$pathcomp$d"
    1.67 +     case "$pathcomp" in
    1.68 +       -* ) pathcomp=./$pathcomp ;;
    1.69 +     esac
    1.70 +
    1.71 +     if test ! -d "$pathcomp"; then
    1.72 +	echo "mkdir $pathcomp"
    1.73 +
    1.74 +	mkdir "$pathcomp" || lasterr=$?
    1.75 +
    1.76 +	if test ! -d "$pathcomp"; then
    1.77 +	  errstatus=$lasterr
    1.78 +	else
    1.79 +	  if test ! -z "$dirmode"; then
    1.80 +	     echo "chmod $dirmode $pathcomp"
    1.81 +
    1.82 +	     lasterr=""
    1.83 +	     chmod "$dirmode" "$pathcomp" || lasterr=$?
    1.84 +
    1.85 +	     if test ! -z "$lasterr"; then
    1.86 +	       errstatus=$lasterr
    1.87 +	     fi
    1.88 +	  fi
    1.89 +	fi
    1.90 +     fi
    1.91 +
    1.92 +     pathcomp="$pathcomp/"
    1.93 +   done
    1.94 +done
    1.95 +
    1.96 +exit $errstatus
    1.97 +
    1.98 +# Local Variables:
    1.99 +# mode: shell-script
   1.100 +# sh-indentation: 3
   1.101 +# End:
   1.102 +# mkinstalldirs ends here