#!/bin/sh
# Provision of this shell script should not be taken to imply that use of
# GNU eqn with groff -Tascii|-Tlatin1|-Tutf8|-Tcp1047 is supported.

# Default device.
# First try the "locale charmap" command, because it's most reliable.
# On systems where it doesn't exist, look at the environment variables.
case "`locale charmap 2>/dev/null`" in
  UTF-8)
    T=-Tutf8 ;;
  ISO-8859-1)
    T=-Tlatin1 ;;
  KOI8-R)
    T=-Tkoi8-r ;;
  IBM-1047)
    T=-Tcp1047 ;;
  *)
    case "${LC_ALL-${LC_CTYPE-${LANG}}}" in
      *.UTF-8)
        T=-Tutf8 ;;
      iso_8859_1 | *.ISO-8859-1)
        T=-Tlatin1 ;;
      KOI8-R | *.KOI8-R | *.koi8-r | ru)
        T=-Tkoi8-r ;;
      *.IBM-1047)
        T=-Tcp1047 ;;
      *)
        case "$LESSCHARSET" in
          utf-8)
            T=-Tutf8 ;;
          latin1)
            T=-Tlatin1 ;;
          koi8-r)
            T=-Tkoi8-r ;;
          cp1047)
            T=-Tcp1047 ;;
          *)
                    # not correct, but at least lets man pages display on screen ...
            T=-Tlatin1 ;;
      esac ;;
   esac ;;
esac


: ${GROFF_BIN_PATH=/usr/bin}
PATH=$GROFF_BIN_PATH:$PATH
export PATH
exec eqn -T${T} ${1+"$@"}

# eof
