#!/bin/sh

# This is teTeX´s xdvi wrapper script, version 0.1.
# Copyright Thomas Esser, 1996. Permission to distribute under the terms
# of the GNU general public license version 2 or later.

# This script sets some environment variables to make sure that xdvi's
# ressource file in $TEXMF/xdvi is read by xdvi.bin.
# Special care was taken to make this work for old R3, too. Therefore,
# we need to modify XAPPLRESDIR. If you are running R4 or later, you
# can set XUSERFILESEARCHPATH for user specific application default
# files. You cannot use XAPPLRESDIR for user specific application default
# files.

# -help and -version only work if they are the only options. Therefore,
# we cannot give the "-name xdvi" parameter in that case.
case "$#:$1" in
  1:-help|1:-version)
    NAMEOPT=;;
  *)
    NAMEOPT='-name xdvi';;
esac
xdviappdir="${TEXMF-`kpsetool -v '\$TEXMF'`}/xdvi/"
xdviapppath="${xdviappdir}%N"

# For R3, we have to set XAPPLRESDIR.
XAPPLRESDIR="$xdviappdir"; export XAPPLRESDIR

# For R4 or later, we have to set XFILESEARCHPATH, since XAPPLRESDIR might
# be ignored (if XUSERFILESEARCHPATH is set)
XFILESEARCHPATH="$xdviapppath:${XFILESEARCHPATH-%D}"; export XFILESEARCHPATH

exec xdvi.bin $NAMEOPT ${1+"$@"}
