ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/dhcpping/mkinstalldirs
Revision: 1.1
Committed: Mon Jul 26 00:46:09 2004 UTC (19 years, 10 months ago) by root
Branch: MAIN
CVS Tags: HEAD
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 root 1.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.1 2002/01/26 14:09:36 mavetju Exp $
8    
9     errstatus=0
10     dirmode=""
11    
12     usage="\
13     Usage: mkinstalldirs [-h] [--help] [-m mode] dir ..."
14    
15     # process command line arguments
16     while 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
29     done
30    
31     for file
32     do
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
67     done
68    
69     exit $errstatus
70    
71     # Local Variables:
72     # mode:shell-script
73     # sh-indentation:3
74     # End: