File: mkdir.sh

package info (click to toggle)
apr 1.6.5-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 7,132 kB
  • sloc: ansic: 60,108; sh: 3,610; perl: 900; awk: 393; makefile: 366; python: 142
file content (43 lines) | stat: -rwxr-xr-x 1,242 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/sh
## 
##  mkdir.sh -- make directory hierarchy
##
##  Based on `mkinstalldirs' from Noah Friedman <friedman@prep.ai.mit.edu>
##  as of 1994-03-25, which was placed in the Public Domain.
##  Cleaned up for Apache's Autoconf-style Interface (APACI)
##  by Ralf S. Engelschall <rse@apache.org>
##
#
# This script falls under the Apache License.
# See http://www.apache.org/docs/LICENSE


umask 022
errstatus=0
for file in ${1+"$@"} ; do 
    set fnord `echo ":$file" |\
               sed -e 's/^:\//%/' -e 's/^://' -e 's/\// /g' -e 's/^%/\//'`
    shift
    pathcomp=
    for d in ${1+"$@"}; do
        pathcomp="$pathcomp$d"
        case "$pathcomp" in
            -* ) pathcomp=./$pathcomp ;;
            ?: ) pathcomp="$pathcomp/" 
                 continue ;;
        esac
        if test ! -d "$pathcomp"; then
            echo "mkdir $pathcomp" 1>&2
            thiserrstatus=0
            mkdir "$pathcomp" || thiserrstatus=$?
            # ignore errors due to races if a parallel mkdir.sh already
            # created the dir
            if test $thiserrstatus != 0 && test ! -d "$pathcomp" ; then
                errstatus=$thiserrstatus
            fi
        fi
        pathcomp="$pathcomp/"
    done
done
exit $errstatus