~ubuntu-branches/ubuntu/lucid/tuxtype/lucid-proposed

« back to all changes in this revision

Viewing changes to mkinstalldirs

  • Committer: Bazaar Package Importer
  • Author(s): Oliver Grawert
  • Date: 2006-10-30 13:48:49 UTC
  • mfrom: (2.1.1 etch)
  • Revision ID: james.westby@ubuntu.com-20061030134849-5fdruftday0c02gs
Tags: 1.5.6.dfsg1-3ubuntu1
Merge from debian unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
# Created: 1993-05-16
5
5
# Public domain
6
6
 
7
 
# $Id: mkinstalldirs,v 1.1.1.1 2000/10/12 02:42:59 criswell Exp $
 
7
# $Id: mkinstalldirs,v 1.6 2004/03/30 01:41:31 calarndt Exp $
8
8
 
9
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
  if test -d "$file"; then
 
34
    shift
 
35
  else
 
36
    break
 
37
  fi
 
38
done
 
39
 
 
40
case $# in
 
41
0) exit 0 ;;
 
42
esac
 
43
 
 
44
case $dirmode in
 
45
'')
 
46
  if mkdir -p -- . 2>/dev/null; then
 
47
    echo "mkdir -p -- $*"
 
48
    exec mkdir -p -- "$@"
 
49
  fi ;;
 
50
*)
 
51
  if mkdir -m "$dirmode" -p -- . 2>/dev/null; then
 
52
    echo "mkdir -m $dirmode -p -- $*"
 
53
    exec mkdir -m "$dirmode" -p -- "$@"
 
54
  fi ;;
 
55
esac
10
56
 
11
57
for file
12
58
do
22
68
     esac
23
69
 
24
70
     if test ! -d "$pathcomp"; then
25
 
        echo "mkdir $pathcomp" 1>&2
26
 
 
27
 
        mkdir "$pathcomp" || lasterr=$?
28
 
 
29
 
        if test ! -d "$pathcomp"; then
30
 
          errstatus=$lasterr
31
 
        fi
 
71
        echo "mkdir $pathcomp"
 
72
 
 
73
        mkdir "$pathcomp" || lasterr=$?
 
74
 
 
75
        if test ! -d "$pathcomp"; then
 
76
          errstatus=$lasterr
 
77
        else
 
78
          if test ! -z "$dirmode"; then
 
79
             echo "chmod $dirmode $pathcomp"
 
80
 
 
81
             lasterr=""
 
82
             chmod "$dirmode" "$pathcomp" || lasterr=$?
 
83
 
 
84
             if test ! -z "$lasterr"; then
 
85
               errstatus=$lasterr
 
86
             fi
 
87
          fi
 
88
        fi
32
89
     fi
33
90
 
34
91
     pathcomp="$pathcomp/"
37
94
 
38
95
exit $errstatus
39
96
 
 
97
# Local Variables:
 
98
# mode: shell-script
 
99
# sh-indentation: 3
 
100
# End:
40
101
# mkinstalldirs ends here