source: trunk/gui/tclconfig/mkinstalldirs @ 827

Last change on this file since 827 was 503, checked in by nkissebe, 18 years ago

Converted to Tcl Extension Architecture (TEA) v3.5 for base Windows support. Added Windows ports of getrlimit, getrusage, gettimeofday, setrlimit functions.

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