#!/bin/sh

case $# in
1) : ;;
*)   echo "usage: $0 dir " >&2; exit 1;;
esac

dir=$1
test -d "$dir" && exit

: ${TEXMF=`kpsetool -v '$TEXMF'`}
: ${MAKETEXDIR=$TEXMF/maketex}
export TEXMF MAKETEXDIR
test -f $MAKETEXDIR/maketex.site && . $MAKETEXDIR/maketex.site

cd /
OLDIFS=$IFS; IFS=/; eval set $dir; IFS=$OLDIFS

for i
do
  test -d "$i" || mkdir "$i" ||
    { echo "$0: could not create directory `pwd`/$i" >&2; exit 1; }
  cd "$i" || { echo "$0: could not cd to `pwd`/$i" >&2; exit 1; }
done
