Erik Grinaker is sharing code with you

Bitbucket is a code hosting site. Unlimited public and private repositories. Free for small teams.

Don't show this again

erikg / Revelation

Revelation is a password manager for the GNOME desktop, released under the GNU GPL license. It stores all your accounts and passwords in a single, secure place, and gives you access to it through a user-friendly graphical interface.

Clone this repository (size: 2.1 MB): HTTPS / SSH
hg clone https://bitbucket.org/erikg/revelation
hg clone ssh://hg@bitbucket.org/erikg/revelation

Revelation / mkinstalldirs

commit
ba434a17e651
parent
e6bf198935fe
branch
default
tags
revelation-0.4.6

set release dates

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