~ubuntu-branches/ubuntu/maverick/zapping/maverick

« back to all changes in this revision

Viewing changes to mkinstalldirs

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2005-03-08 23:19:08 UTC
  • mfrom: (2.1.1 sarge)
  • Revision ID: james.westby@ubuntu.com-20050308231908-oip7rfv6lcmo8c0e
Tags: 0.9.2-2ubuntu1
Rebuilt for Python transition (2.3 -> 2.4)

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.13 1999/01/05 03:18:55 bje Exp $
8
 
 
9
7
errstatus=0
10
8
dirmode=""
11
9
 
14
12
 
15
13
# process command line arguments
16
14
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
 
15
  case $1 in
 
16
    -h | --help | --h*)         # -h for help
 
17
      echo "$usage" 1>&2
 
18
      exit 0
 
19
      ;;
 
20
    -m)                         # -m PERM arg
 
21
      shift
 
22
      test $# -eq 0 && { echo "$usage" 1>&2; exit 1; }
 
23
      dirmode=$1
 
24
      shift
 
25
      ;;
 
26
    --)                         # stop option processing
 
27
      shift
 
28
      break
 
29
      ;;
 
30
    -*)                         # unknown option
 
31
      echo "$usage" 1>&2
 
32
      exit 1
 
33
      ;;
 
34
    *)                          # first non-opt arg
 
35
      break
 
36
      ;;
 
37
  esac
29
38
done
30
39
 
31
40
for file
38
47
done
39
48
 
40
49
case $# in
41
 
0) exit 0 ;;
 
50
  0) exit 0 ;;
42
51
esac
43
52
 
44
53
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 ;;
 
54
  '')
 
55
    if mkdir -p -- . 2>/dev/null; then
 
56
      echo "mkdir -p -- $*"
 
57
      exec mkdir -p -- "$@"
 
58
    fi
 
59
    ;;
 
60
  *)
 
61
    if mkdir -m "$dirmode" -p -- . 2>/dev/null; then
 
62
      echo "mkdir -m $dirmode -p -- $*"
 
63
      exec mkdir -m "$dirmode" -p -- "$@"
 
64
    fi
 
65
    ;;
55
66
esac
56
67
 
57
68
for file
58
69
do
59
 
   set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
60
 
   shift
61
 
 
62
 
   pathcomp=
63
 
   for d
64
 
   do
65
 
     pathcomp="$pathcomp$d"
66
 
     case "$pathcomp" in
67
 
       -* ) pathcomp=./$pathcomp ;;
68
 
     esac
69
 
 
70
 
     if test ! -d "$pathcomp"; then
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
89
 
     fi
90
 
 
91
 
     pathcomp="$pathcomp/"
92
 
   done
 
70
  set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
 
71
  shift
 
72
 
 
73
  pathcomp=
 
74
  for d
 
75
  do
 
76
    pathcomp="$pathcomp$d"
 
77
    case $pathcomp in
 
78
      -*) pathcomp=./$pathcomp ;;
 
79
    esac
 
80
 
 
81
    if test ! -d "$pathcomp"; then
 
82
      echo "mkdir $pathcomp"
 
83
 
 
84
      mkdir "$pathcomp" || lasterr=$?
 
85
 
 
86
      if test ! -d "$pathcomp"; then
 
87
        errstatus=$lasterr
 
88
      else
 
89
        if test ! -z "$dirmode"; then
 
90
          echo "chmod $dirmode $pathcomp"
 
91
          lasterr=""
 
92
          chmod "$dirmode" "$pathcomp" || lasterr=$?
 
93
 
 
94
          if test ! -z "$lasterr"; then
 
95
            errstatus=$lasterr
 
96
          fi
 
97
        fi
 
98
      fi
 
99
    fi
 
100
 
 
101
    pathcomp="$pathcomp/"
 
102
  done
93
103
done
94
104
 
95
105
exit $errstatus
96
106
 
97
107
# Local Variables:
98
108
# mode: shell-script
99
 
# sh-indentation: 3
 
109
# sh-indentation: 2
100
110
# End:
101
111
# mkinstalldirs ends here