beta-0.89.2
[luatex.git] / source / texk / kpathsea / mktexdir
blobf39408b4c1f24616dc36968229bfc6cf1f4c8f74
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.
9 version='$Id: mktexdir 34656 2014-07-18 23:38:50Z karl $'
10 progname=`echo $0 | sed 's%.*/%%'`
12 # preferentially use subprograms from our own directory.
13 mydir=`echo "$0" | sed 's,/[^/]*$,,'`
14 mydir=`cd "$mydir" && pwd`
15 PATH="$mydir:$PATH"; export PATH
17 usage="Usage: $0 DIR...
18 Create each DIR, including any missing leading directories."
19 mt_max_args=$#
21 # Common code for all scripts.
22 : ${MT_TEXMFMAIN=`kpsewhich --expand-path='$TEXMFMAIN'`}
23 : ${MT_MKTEX_OPT=`kpsewhich --format='web2c files' mktex.opt`}
24 test -n "$MT_MKTEX_OPT" || MT_MKTEX_OPT="$MT_TEXMFMAIN/web2c/mktex.opt"
25 if test ! -f "$MT_MKTEX_OPT"; then
26 echo "$0: Cannot find mktex.opt; check your installation." >&2
27 exit 1
30 . "$MT_MKTEX_OPT"
32 test -n "$MT_MKTEXDIR_OPT" && . "$MT_MKTEXDIR_OPT"
34 test -z "$MT_APPEND_MASK" && MT_APPEND_MASK="="
36 errstatus=0
38 for file
40 case $file in
41 /*) cd /;;
42 *) cd $KPSE_DOT;;
43 esac
44 OLDIFS=$IFS; IFS=/; set fnord `echo "./$file"`; IFS=$OLDIFS; shift
46 pathcomp=
47 for d
49 test -z "$d" && continue
50 pathcomp="$pathcomp$d"
52 if test ! -d "./$pathcomp"; then
53 mkdir "./$pathcomp" || { errstatus=$?; break; }
54 chmod `kpsestat ${MT_APPEND_MASK} "$pathcomp"/..` "./$pathcomp"
57 pathcomp="$pathcomp/"
58 done
59 done
61 exit $errstatus