1#!/bin/sh
2# mkinstalldirs (now mktexdir) -- make directory hierarchy.
3# Author: Noah Friedman <friedman@prep.ai.mit.edu>, created: 1993-05-16.
4# Public domain.
5#
6# Modified for sticky directory creation, --help, --version, more,
7# by Thomas Esser, Karl Berry, Olaf Weber, et al.
8
9version='$Id: mktexdir,v 1.11 2013/03/13 20:24:27 vojta Exp $'
10usage="Usage: $0 DIRS...
11  Create each DIR, including any missing leading directories."
12mt_max_args=$#
13
14# Common code for all scripts.
15: ${MT_TEXMFMAIN=`kpsewhich --expand-path='$TEXMFMAIN'`}
16: ${MT_MKTEX_OPT=`kpsewhich --format='web2c files' mktex.opt`}
17test -n "$MT_MKTEX_OPT" || MT_MKTEX_OPT="$MT_TEXMFMAIN/web2c/mktex.opt"
18if test ! -f "$MT_MKTEX_OPT"; then
19  echo "$0: Cannot find mktex.opt; check your installation." >&2
20  exit 1
21fi
22
23. "$MT_MKTEX_OPT"
24
25test -n "$MT_MKTEXDIR_OPT" && . "$MT_MKTEXDIR_OPT"
26
27test -z "$MT_APPEND_MASK" && MT_APPEND_MASK="="
28
29errstatus=0
30
31for file
32do
33   case $file in
34     /*) cd /;;
35     *) cd $KPSE_DOT;;
36   esac
37   OLDIFS=$IFS; IFS=/; set fnord `echo "./$file"`; IFS=$OLDIFS; shift
38
39   pathcomp=
40   for d
41   do
42     test -z "$d" && continue
43     pathcomp="$pathcomp$d"
44
45     if test ! -d "./$pathcomp"; then
46        mkdir "./$pathcomp" || { errstatus=$?; break; }
47        chmod `kpsestat ${MT_APPEND_MASK} "$pathcomp"/..` "./$pathcomp"
48     fi
49
50     pathcomp="$pathcomp/"
51   done
52done
53
54exit $errstatus
55