Sync usage with man page.
[netbsd-mini2440.git] / gnu / dist / autoconf / config / mkinstalldirs
blob5157e18213a8d3bf3dbf9008381661cf357105a4
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
7 # $Id: mkinstalldirs,v 1.1.1.1 2001/11/14 19:47:46 tv Exp $
9 errstatus=0
10 dirmode=""
12 usage="\
13 Usage: mkinstalldirs [-h] [--help] [-m mode] dir ..."
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
31 for file
33 set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
34 shift
36 pathcomp=
37 for d
39 pathcomp="$pathcomp$d"
40 case "$pathcomp" in
41 -* ) pathcomp=./$pathcomp ;;
42 esac
44 if test ! -d "$pathcomp"; then
45 echo "mkdir $pathcomp"
47 mkdir "$pathcomp" || lasterr=$?
49 if test ! -d "$pathcomp"; then
50 errstatus=$lasterr
51 else
52 if test ! -z "$dirmode"; then
53 echo "chmod $dirmode $pathcomp"
55 lasterr=""
56 chmod $dirmode "$pathcomp" || lasterr=$?
58 if test ! -z "$lasterr"; then
59 errstatus=$lasterr
65 pathcomp="$pathcomp/"
66 done
67 done
69 exit $errstatus
71 # Local Variables:
72 # mode:shell-script
73 # sh-indentation:3
74 # End: