#!/bin/sh

# This is the xdvi wrapper script for teTeX, version 0.2.
# Copyright Thomas Esser, 1998. 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
# resource file in $XDVIINPUTS/xdvi is read by xdvi.bin.

# -help and -version only used to work if they were the only options,
# so the "-name xdvi" parameter wasn't used in that case. With current
# xdvik, it should work in any case, but we keep this logic for compatibility
# with older xdvik and plain xdvi versions.
have_basename=`basename foo/bar 2>&1 | grep -i 'not found'`
if [ "$have_basename"xxx = "xxx" ]; then
    BASE_NAME=`basename $0`
else
    BASE_NAME=`echo $0 | sed 's!.*/!!'`
fi

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

exec xdvi-xaw $NAMEOPT ${1+"$@"}
