build-scripts/mkinstalldirs
author Alex Szpakowski <slime73@gmail.com>
Sun, 14 Oct 2018 17:26:10 -0300
changeset 12326 f8309eaee217
parent 1361 19418e4422cb
child 12335 5e68900d2232
permissions -rwxr-xr-x
iOS: Don't ignore the requested alpha bit size when determining whether to use an RGBA8 backbuffer.
slouken@1361
     1
#! /bin/sh
slouken@1361
     2
# mkinstalldirs --- make directory hierarchy
slouken@1361
     3
# Author: Noah Friedman <friedman@prep.ai.mit.edu>
slouken@1361
     4
# Created: 1993-05-16
slouken@1361
     5
# Public domain
slouken@1361
     6
slouken@1361
     7
errstatus=0
slouken@1361
     8
dirmode=""
slouken@1361
     9
slouken@1361
    10
usage="\
slouken@1361
    11
Usage: mkinstalldirs [-h] [--help] [-m mode] dir ..."
slouken@1361
    12
slouken@1361
    13
# process command line arguments
slouken@1361
    14
while test $# -gt 0 ; do
slouken@1361
    15
   case "${1}" in
slouken@1361
    16
     -h | --help | --h* )			# -h for help
slouken@1361
    17
	echo "${usage}" 1>&2; exit 0 ;;
slouken@1361
    18
     -m )					# -m PERM arg
slouken@1361
    19
	shift
slouken@1361
    20
	test $# -eq 0 && { echo "${usage}" 1>&2; exit 1; }
slouken@1361
    21
	dirmode="${1}"
slouken@1361
    22
	shift ;;
slouken@1361
    23
     -- ) shift; break ;;			# stop option processing
slouken@1361
    24
     -* ) echo "${usage}" 1>&2; exit 1 ;;	# unknown option
slouken@1361
    25
     * )  break ;;				# first non-opt arg
slouken@1361
    26
   esac
slouken@1361
    27
done
slouken@1361
    28
slouken@1361
    29
for file
slouken@1361
    30
do
slouken@1361
    31
  if test -d "$file"; then
slouken@1361
    32
    shift
slouken@1361
    33
  else
slouken@1361
    34
    break
slouken@1361
    35
  fi
slouken@1361
    36
done
slouken@1361
    37
slouken@1361
    38
case $# in
slouken@1361
    39
0) exit 0 ;;
slouken@1361
    40
esac
slouken@1361
    41
slouken@1361
    42
case $dirmode in
slouken@1361
    43
'')
slouken@1361
    44
  if mkdir -p -- . 2>/dev/null; then
slouken@1361
    45
    echo "mkdir -p -- $*"
slouken@1361
    46
    exec mkdir -p -- "$@"
slouken@1361
    47
  fi ;;
slouken@1361
    48
*)
slouken@1361
    49
  if mkdir -m "$dirmode" -p -- . 2>/dev/null; then
slouken@1361
    50
    echo "mkdir -m $dirmode -p -- $*"
slouken@1361
    51
    exec mkdir -m "$dirmode" -p -- "$@"
slouken@1361
    52
  fi ;;
slouken@1361
    53
esac
slouken@1361
    54
slouken@1361
    55
for file
slouken@1361
    56
do
slouken@1361
    57
   set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
slouken@1361
    58
   shift
slouken@1361
    59
slouken@1361
    60
   pathcomp=
slouken@1361
    61
   for d
slouken@1361
    62
   do
slouken@1361
    63
     pathcomp="$pathcomp$d"
slouken@1361
    64
     case "$pathcomp" in
slouken@1361
    65
       -* ) pathcomp=./$pathcomp ;;
slouken@1361
    66
     esac
slouken@1361
    67
slouken@1361
    68
     if test ! -d "$pathcomp"; then
slouken@1361
    69
	echo "mkdir $pathcomp"
slouken@1361
    70
slouken@1361
    71
	mkdir "$pathcomp" || lasterr=$?
slouken@1361
    72
slouken@1361
    73
	if test ! -d "$pathcomp"; then
slouken@1361
    74
	  errstatus=$lasterr
slouken@1361
    75
	else
slouken@1361
    76
	  if test ! -z "$dirmode"; then
slouken@1361
    77
	     echo "chmod $dirmode $pathcomp"
slouken@1361
    78
slouken@1361
    79
	     lasterr=""
slouken@1361
    80
	     chmod "$dirmode" "$pathcomp" || lasterr=$?
slouken@1361
    81
slouken@1361
    82
	     if test ! -z "$lasterr"; then
slouken@1361
    83
	       errstatus=$lasterr
slouken@1361
    84
	     fi
slouken@1361
    85
	  fi
slouken@1361
    86
	fi
slouken@1361
    87
     fi
slouken@1361
    88
slouken@1361
    89
     pathcomp="$pathcomp/"
slouken@1361
    90
   done
slouken@1361
    91
done
slouken@1361
    92
slouken@1361
    93
exit $errstatus
slouken@1361
    94
slouken@1361
    95
# Local Variables:
slouken@1361
    96
# mode: shell-script
slouken@1361
    97
# sh-indentation: 3
slouken@1361
    98
# End:
slouken@1361
    99
# mkinstalldirs ends here