xref: /aosp_15_r20/external/cronet/third_party/apache-portable-runtime/src/build/mkdir.sh (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1#!/bin/sh
2##
3##  mkdir.sh -- make directory hierarchy
4##
5##  Based on `mkinstalldirs' from Noah Friedman <[email protected]>
6##  as of 1994-03-25, which was placed in the Public Domain.
7##  Cleaned up for Apache's Autoconf-style Interface (APACI)
8##  by Ralf S. Engelschall <[email protected]>
9##
10#
11# This script falls under the Apache License.
12# See http://www.apache.org/docs/LICENSE
13
14
15umask 022
16errstatus=0
17for file in ${1+"$@"} ; do
18    set fnord `echo ":$file" |\
19               sed -e 's/^:\//%/' -e 's/^://' -e 's/\// /g' -e 's/^%/\//'`
20    shift
21    pathcomp=
22    for d in ${1+"$@"}; do
23        pathcomp="$pathcomp$d"
24        case "$pathcomp" in
25            -* ) pathcomp=./$pathcomp ;;
26            ?: ) pathcomp="$pathcomp/"
27                 continue ;;
28        esac
29        if test ! -d "$pathcomp"; then
30            echo "mkdir $pathcomp" 1>&2
31            thiserrstatus=0
32            mkdir "$pathcomp" || thiserrstatus=$?
33            # ignore errors due to races if a parallel mkdir.sh already
34            # created the dir
35            if test $thiserrstatus != 0 && test ! -d "$pathcomp" ; then
36                errstatus=$thiserrstatus
37            fi
38        fi
39        pathcomp="$pathcomp/"
40    done
41done
42exit $errstatus
43
44