Mercurial > hg > index.fcgi > gift-gnutella > gift-gnutella-0.0.11-1pba
diff mkinstalldirs @ 0:d39e1d0d75b6
initial add
author | paulo@hit-nxdomain.opendns.com |
---|---|
date | Sat, 20 Feb 2010 21:18:28 -0800 |
parents | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/mkinstalldirs Sat Feb 20 21:18:28 2010 -0800 1.3 @@ -0,0 +1,111 @@ 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 1.21 + exit 0 1.22 + ;; 1.23 + -m) # -m PERM arg 1.24 + shift 1.25 + test $# -eq 0 && { echo "$usage" 1>&2; exit 1; } 1.26 + dirmode=$1 1.27 + shift 1.28 + ;; 1.29 + --) # stop option processing 1.30 + shift 1.31 + break 1.32 + ;; 1.33 + -*) # unknown option 1.34 + echo "$usage" 1>&2 1.35 + exit 1 1.36 + ;; 1.37 + *) # first non-opt arg 1.38 + break 1.39 + ;; 1.40 + esac 1.41 +done 1.42 + 1.43 +for file 1.44 +do 1.45 + if test -d "$file"; then 1.46 + shift 1.47 + else 1.48 + break 1.49 + fi 1.50 +done 1.51 + 1.52 +case $# in 1.53 + 0) exit 0 ;; 1.54 +esac 1.55 + 1.56 +case $dirmode in 1.57 + '') 1.58 + if mkdir -p -- . 2>/dev/null; then 1.59 + echo "mkdir -p -- $*" 1.60 + exec mkdir -p -- "$@" 1.61 + fi 1.62 + ;; 1.63 + *) 1.64 + if mkdir -m "$dirmode" -p -- . 2>/dev/null; then 1.65 + echo "mkdir -m $dirmode -p -- $*" 1.66 + exec mkdir -m "$dirmode" -p -- "$@" 1.67 + fi 1.68 + ;; 1.69 +esac 1.70 + 1.71 +for file 1.72 +do 1.73 + set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` 1.74 + shift 1.75 + 1.76 + pathcomp= 1.77 + for d 1.78 + do 1.79 + pathcomp="$pathcomp$d" 1.80 + case $pathcomp in 1.81 + -*) pathcomp=./$pathcomp ;; 1.82 + esac 1.83 + 1.84 + if test ! -d "$pathcomp"; then 1.85 + echo "mkdir $pathcomp" 1.86 + 1.87 + mkdir "$pathcomp" || lasterr=$? 1.88 + 1.89 + if test ! -d "$pathcomp"; then 1.90 + errstatus=$lasterr 1.91 + else 1.92 + if test ! -z "$dirmode"; then 1.93 + echo "chmod $dirmode $pathcomp" 1.94 + lasterr="" 1.95 + chmod "$dirmode" "$pathcomp" || lasterr=$? 1.96 + 1.97 + if test ! -z "$lasterr"; then 1.98 + errstatus=$lasterr 1.99 + fi 1.100 + fi 1.101 + fi 1.102 + fi 1.103 + 1.104 + pathcomp="$pathcomp/" 1.105 + done 1.106 +done 1.107 + 1.108 +exit $errstatus 1.109 + 1.110 +# Local Variables: 1.111 +# mode: shell-script 1.112 +# sh-indentation: 2 1.113 +# End: 1.114 +# mkinstalldirs ends here