The R Project SVN R

Rev

Rev 26592 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 26592 Rev 28188
1
#! /bin/sh
1
#! /bin/sh
2
# mkinstalldirs --- make directory hierarchy
2
# mkinstalldirs --- make directory hierarchy
-
 
3
 
-
 
4
scriptversion=2003-11-08.23
-
 
5
 
3
# Original author: Noah Friedman <friedman@prep.ai.mit.edu>
6
# Original author: Noah Friedman <friedman@prep.ai.mit.edu>
4
# Created: 1993-05-16
7
# Created: 1993-05-16
5
# Public domain.
8
# Public domain.
6
 
9
#
-
 
10
# This file is maintained in Automake, please report
-
 
11
# bugs to <bug-automake@gnu.org> or send patches to
7
scriptversion=2003-09-26.19
12
# <automake-patches@gnu.org>.
8
 
13
 
9
errstatus=0
14
errstatus=0
10
dirmode=""
15
dirmode=""
11
 
16
 
12
usage="\
17
usage="\
13
Usage: mkinstalldirs [-h] [--help] [--version] [-m MODE] DIR ...
18
Usage: mkinstalldirs [-h] [--help] [--version] [-m MODE] DIR ...
14
 
19
 
15
Create each directory DIR (with mode MODE, if specified), including all
20
Create each directory DIR (with mode MODE, if specified), including all
16
leading file name components.
21
leading file name components.
17
"
22
 
-
 
23
Report bugs to <bug-automake@gnu.org>."
18
 
24
 
19
# process command line arguments
25
# process command line arguments
20
while test $# -gt 0 ; do
26
while test $# -gt 0 ; do
21
  case $1 in
27
  case $1 in
22
    -h | --help | --h*)         # -h for help
28
    -h | --help | --h*)         # -h for help
23
      echo "$usage"
29
      echo "$usage"
24
      exit 0
30
      exit 0
25
      ;;
31
      ;;
26
    -m)                         # -m PERM arg
32
    -m)                         # -m PERM arg
27
      shift
33
      shift
28
      test $# -eq 0 && { echo "$usage" 1>&2; exit 1; }
34
      test $# -eq 0 && { echo "$usage" 1>&2; exit 1; }
29
      dirmode=$1
35
      dirmode=$1
30
      shift
36
      shift
31
      ;;
37
      ;;
32
    --version)
38
    --version)
33
      echo "$0 $scriptversion"
39
      echo "$0 $scriptversion"
34
      exit 0
40
      exit 0
35
      ;;
41
      ;;
36
    --)                         # stop option processing
42
    --)                         # stop option processing
37
      shift
43
      shift
38
      break
44
      break
39
      ;;
45
      ;;
40
    -*)                         # unknown option
46
    -*)                         # unknown option
41
      echo "$usage" 1>&2
47
      echo "$usage" 1>&2
42
      exit 1
48
      exit 1
43
      ;;
49
      ;;
44
    *)                          # first non-opt arg
50
    *)                          # first non-opt arg
45
      break
51
      break
46
      ;;
52
      ;;
47
  esac
53
  esac
48
done
54
done
49
 
55
 
50
for file
56
for file
51
do
57
do
52
  if test -d "$file"; then
58
  if test -d "$file"; then
53
    shift
59
    shift
54
  else
60
  else
55
    break
61
    break
56
  fi
62
  fi
57
done
63
done
58
 
64
 
59
case $# in
65
case $# in
60
  0) exit 0 ;;
66
  0) exit 0 ;;
61
esac
67
esac
62
 
68
 
63
case $dirmode in
69
case $dirmode in
64
  '')
70
  '')
65
    if mkdir -p -- . 2>/dev/null; then
71
    if mkdir -p -- . 2>/dev/null; then
66
      echo "mkdir -p -- $*"
72
      echo "mkdir -p -- $*"
67
      exec mkdir -p -- "$@"
73
      exec mkdir -p -- "$@"
68
    else
74
    else
69
      # On NextStep and OpenStep, the `mkdir' command does not
75
      # On NextStep and OpenStep, the `mkdir' command does not
70
      # recognize any option.  It will interpret all options as
76
      # recognize any option.  It will interpret all options as
71
      # directories to create, and then abort because `.' already
77
      # directories to create, and then abort because `.' already
72
      # exists.
78
      # exists.
73
      test -d ./-p && rmdir ./-p
79
      test -d ./-p && rmdir ./-p
74
      test -d ./-- && rmdir ./--
80
      test -d ./-- && rmdir ./--
75
    fi
81
    fi
76
    ;;
82
    ;;
77
  *)
83
  *)
78
    if mkdir -m "$dirmode" -p -- . 2>/dev/null; then
84
    if mkdir -m "$dirmode" -p -- . 2>/dev/null; then
79
      echo "mkdir -m $dirmode -p -- $*"
85
      echo "mkdir -m $dirmode -p -- $*"
80
      exec mkdir -m "$dirmode" -p -- "$@"
86
      exec mkdir -m "$dirmode" -p -- "$@"
81
    else
87
    else
82
      # Clean up after NextStep and OpenStep mkdir.
88
      # Clean up after NextStep and OpenStep mkdir.
83
      for d in ./-m ./-p ./-- "./$dirmode";
89
      for d in ./-m ./-p ./-- "./$dirmode";
84
      do
90
      do
85
        test -d $d && rmdir $d
91
        test -d $d && rmdir $d
86
      done
92
      done
87
    fi
93
    fi
88
    ;;
94
    ;;
89
esac
95
esac
90
 
96
 
91
for file
97
for file
92
do
98
do
93
  set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
99
  set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
94
  shift
100
  shift
95
 
101
 
96
  pathcomp=
102
  pathcomp=
97
  for d
103
  for d
98
  do
104
  do
99
    pathcomp="$pathcomp$d"
105
    pathcomp="$pathcomp$d"
100
    case $pathcomp in
106
    case $pathcomp in
101
      -*) pathcomp=./$pathcomp ;;
107
      -*) pathcomp=./$pathcomp ;;
102
    esac
108
    esac
103
 
109
 
104
    if test ! -d "$pathcomp"; then
110
    if test ! -d "$pathcomp"; then
105
      echo "mkdir $pathcomp"
111
      echo "mkdir $pathcomp"
106
 
112
 
107
      mkdir "$pathcomp" || lasterr=$?
113
      mkdir "$pathcomp" || lasterr=$?
108
 
114
 
109
      if test ! -d "$pathcomp"; then
115
      if test ! -d "$pathcomp"; then
110
	errstatus=$lasterr
116
	errstatus=$lasterr
111
      else
117
      else
112
	if test ! -z "$dirmode"; then
118
	if test ! -z "$dirmode"; then
113
	  echo "chmod $dirmode $pathcomp"
119
	  echo "chmod $dirmode $pathcomp"
114
	  lasterr=""
120
	  lasterr=""
115
	  chmod "$dirmode" "$pathcomp" || lasterr=$?
121
	  chmod "$dirmode" "$pathcomp" || lasterr=$?
116
 
122
 
117
	  if test ! -z "$lasterr"; then
123
	  if test ! -z "$lasterr"; then
118
	    errstatus=$lasterr
124
	    errstatus=$lasterr
119
	  fi
125
	  fi
120
	fi
126
	fi
121
      fi
127
      fi
122
    fi
128
    fi
123
 
129
 
124
    pathcomp="$pathcomp/"
130
    pathcomp="$pathcomp/"
125
  done
131
  done
126
done
132
done
127
 
133
 
128
exit $errstatus
134
exit $errstatus
129
 
135
 
130
# Local Variables:
136
# Local Variables:
131
# mode: shell-script
137
# mode: shell-script
132
# sh-indentation: 2
138
# sh-indentation: 2
133
# eval: (add-hook 'write-file-hooks 'time-stamp)
139
# eval: (add-hook 'write-file-hooks 'time-stamp)
134
# time-stamp-start: "scriptversion="
140
# time-stamp-start: "scriptversion="
135
# time-stamp-format: "%:y-%02m-%02d.%02H"
141
# time-stamp-format: "%:y-%02m-%02d.%02H"
136
# time-stamp-end: "$"
142
# time-stamp-end: "$"
137
# End:
143
# End: