1#! /bin/sh 2# mkinstalldirs --- make directory hierarchy 3# Author: Noah Friedman <friedman@prep.ai.mit.edu> 4# Created: 1993-05-16 5# Public domain 6 7# $Id: mkinstalldirs,v 1.14 1999/04/09 21:44:01 bje Exp $ 8 9errstatus=0 10dirmode="" 11 12usage="\ 13Usage: mkinstalldirs [-h] [--help] [-m mode] dir ..." 14 15# process command line arguments 16while test $# -gt 0 ; do 17 case "${1}" in 18 -h | --help | --h* ) # -h for help 19 echo "${usage}" 1>&2; exit 0 ;; 20 -m ) # -m PERM arg 21 shift 22 test $# -eq 0 && { echo "${usage}" 1>&2; exit 1; } 23 dirmode="${1}" 24 shift ;; 25 -- ) shift; break ;; # stop option processing 26 -* ) echo "${usage}" 1>&2; exit 1 ;; # unknown option 27 * ) break ;; # first non-opt arg 28 esac 29done 30 31for file 32do 33 set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` 34 shift 35 36 pathcomp= 37 for d 38 do 39 pathcomp="$pathcomp$d" 40 case "$pathcomp" in 41 -* ) pathcomp=./$pathcomp ;; 42 esac 43 44 if test ! -d "$pathcomp"; then 45 echo "mkdir $pathcomp" 46 47 mkdir "$pathcomp" || lasterr=$? 48 49 if test ! -d "$pathcomp"; then 50 errstatus=$lasterr 51 else 52 if test ! -z "$dirmode"; then 53 echo "chmod $dirmode $pathcomp" 54 55 lasterr="" 56 chmod $dirmode "$pathcomp" || lasterr=$? 57 58 if test ! -z "$lasterr"; then 59 errstatus=$lasterr 60 fi 61 fi 62 fi 63 fi 64 65 pathcomp="$pathcomp/" 66 done 67done 68 69exit $errstatus 70 71# Local Variables: 72# mode:shell-script 73# sh-indentation:3 74# End: 75