filename | mkinstalldirs |
changeset | 491:515c81624943 |
author | nkeynes |
date | Mon Jan 21 11:59:46 2008 +0000 (15 years ago) |
permissions | -rw-r--r-- |
last change | Fix MAC.L/MAC.W stack issues Fix various recovery-table issues |
file | annotate | diff | log | raw |
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +00001.2 +++ b/mkinstalldirs Mon Jan 21 11:59:46 2008 +00001.3 @@ -0,0 +1,111 @@1.4 +#! /bin/sh1.5 +# mkinstalldirs --- make directory hierarchy1.6 +# Author: Noah Friedman <friedman@prep.ai.mit.edu>1.7 +# Created: 1993-05-161.8 +# Public domain1.9 +1.10 +errstatus=01.11 +dirmode=""1.12 +1.13 +usage="\1.14 +Usage: mkinstalldirs [-h] [--help] [-m mode] dir ..."1.15 +1.16 +# process command line arguments1.17 +while test $# -gt 0 ; do1.18 + case $1 in1.19 + -h | --help | --h*) # -h for help1.20 + echo "$usage" 1>&21.21 + exit 01.22 + ;;1.23 + -m) # -m PERM arg1.24 + shift1.25 + test $# -eq 0 && { echo "$usage" 1>&2; exit 1; }1.26 + dirmode=$11.27 + shift1.28 + ;;1.29 + --) # stop option processing1.30 + shift1.31 + break1.32 + ;;1.33 + -*) # unknown option1.34 + echo "$usage" 1>&21.35 + exit 11.36 + ;;1.37 + *) # first non-opt arg1.38 + break1.39 + ;;1.40 + esac1.41 +done1.42 +1.43 +for file1.44 +do1.45 + if test -d "$file"; then1.46 + shift1.47 + else1.48 + break1.49 + fi1.50 +done1.51 +1.52 +case $# in1.53 + 0) exit 0 ;;1.54 +esac1.55 +1.56 +case $dirmode in1.57 + '')1.58 + if mkdir -p -- . 2>/dev/null; then1.59 + echo "mkdir -p -- $*"1.60 + exec mkdir -p -- "$@"1.61 + fi1.62 + ;;1.63 + *)1.64 + if mkdir -m "$dirmode" -p -- . 2>/dev/null; then1.65 + echo "mkdir -m $dirmode -p -- $*"1.66 + exec mkdir -m "$dirmode" -p -- "$@"1.67 + fi1.68 + ;;1.69 +esac1.70 +1.71 +for file1.72 +do1.73 + set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`1.74 + shift1.75 +1.76 + pathcomp=1.77 + for d1.78 + do1.79 + pathcomp="$pathcomp$d"1.80 + case $pathcomp in1.81 + -*) pathcomp=./$pathcomp ;;1.82 + esac1.83 +1.84 + if test ! -d "$pathcomp"; then1.85 + echo "mkdir $pathcomp"1.86 +1.87 + mkdir "$pathcomp" || lasterr=$?1.88 +1.89 + if test ! -d "$pathcomp"; then1.90 + errstatus=$lasterr1.91 + else1.92 + if test ! -z "$dirmode"; then1.93 + echo "chmod $dirmode $pathcomp"1.94 + lasterr=""1.95 + chmod "$dirmode" "$pathcomp" || lasterr=$?1.96 +1.97 + if test ! -z "$lasterr"; then1.98 + errstatus=$lasterr1.99 + fi1.100 + fi1.101 + fi1.102 + fi1.103 +1.104 + pathcomp="$pathcomp/"1.105 + done1.106 +done1.107 +1.108 +exit $errstatus1.109 +1.110 +# Local Variables:1.111 +# mode: shell-script1.112 +# sh-indentation: 21.113 +# End:1.114 +# mkinstalldirs ends here
.