#!/bin/sh
#	BSDI	Xshownonascii,v 1.2 1995/12/10 06:55:34 sanders Exp
#
MYFONTDIR=/usr/X11/lib/X11/fonts/misc

CHARSET="$1"
shift
if [ "$1" == "-e" ]; then
    shift
    CMD="$*"
    RIGHTTERMCMD="$*"
else
    CMD="${PAGER:-more} $* /dev/null"
    RIGHTTERMCMD="${PAGER:-more} $*"
fi
if [ "$MM_CHARSET" ]; then
    if [ $MM_CHARSET == "$CHARSET" ]; then
	$RIGHTTERMCMD
	exit $?
    fi
fi
if [ "$MM_AUXCHARSETS" ]; then
    if expr "$MM_AUXCHARSETS" : ".*${CHARSET}" > /dev/null; then
	$RIGHTTERMCMD
	exit $?
    fi
fi
if [ ! -d "$MYFONTDIR" ]; then
    echo This message contains non-ASCII text, but the $CHARSET font
    echo has apparently not yet been installed on this machine.  
    echo "(There is no directory named ${MYFONTDIR}.)"
    echo "What follows may be partially unreadable, but the English (ASCII) parts"
    echo "should still be readable."
    echo ""
    cat $*
    exit 0
fi

if [ -z "$DISPLAY" ]; then
    echo This message contains non-ASCII text, which can only be displayed
    echo properly if you are running X11.  What follows
    echo "may be partially unreadable, but the English (ASCII) parts"
    echo "should still be readable."
    cat $*
    exit 0
fi
FPGREP=`xset q | grep $MYFONTDIR`
if [ "$FPGREP" == "" ]; then
    echo Adding $MYFONTDIR to your font path.
    xset +fp $MYFONTDIR
else
    echo Your font path appears to be correctly set.
fi
echo Running xterm to display text in $CHARSET, please wait...
unset MM_NOTTTY

# The following line might work better on IBM RT and other machines that 
#      think it smart inhibit 8 bit chars in xterms.
# xterm -fn $CHARSET -tm litout -e $CMD
XCHARSET=\*`echo $CHARSET | sed -e s/iso-/iso/`
xterm -fn "$XCHARSET" -e $CMD
