#!/bin/sh

case "$#:$1" in
  1:-help|1:-version)
    NAMEOPT=;;
  *)
    NAMEOPT='-name xdvi';;
esac

xdviappdir="${TEXMF-`kpsetool -v '\$TEXMF'`}/xdvi/"
xdviapppath="${xdviappdir}%N"

case "$XUSERFILESEARCHPATH" in
  "") XAPPLRESDIR="$xdviappdir"; export XAPPLRESDIR;;
  *) XUSERFILESEARCHPATH="$xdviapppath:$XUSERFILESEARCHPATH"
     export XUSERFILESEARCHPATH;;
esac

case "$XFILESEARCHPATH" in
  "") XAPPLRESDIR="$xdviappdir"; export XAPPLRESDIR;;
  *) XFILESEARCHPATH="$xdviapppath:$XFILESEARCHPATH"
     export XFILESEARCHPATH;;
esac

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