#!/bin/bash
# Copyright (c) 1999 Fumitoshi UKAI <ukai@debian.or.jp>
# Copyright (c) 1999 Jacobo Tarrio Barreiro <jtarrio@iname.com>
# Copyright (c) 2001 SATO Satoru <ssato@redhat.com>
# Copyright (c) 2002 Akira TAGOH <tagoh@redhat.com>
# This program is covered by the GNU General Public License version 2
#
# ChangeLog:
# * Fri Feb  9 2001 SATO Satoru <ssato@redhat.com>
# - ported from Debian sid
#
# * Fri Aug  9 2001 SATO Satoru <ssato@redhat.com>
# - the default rh's title page will be opened when empty URL is given for
#

## defaults
bindir=/usr/bin
ext="en"
w3m_bin=${bindir}/w3m-${ext}
http_home_dir="/usr/share/doc/HTML"
http_home=${http_home_dir}/index.html


[ -x ${bindir}/locale ] && eval `locale`
locale=`echo ${LC_ALL:-$LANG} | sed -e 's/^\([a-zA-Z_]*\).*/\1/'`

case X"$locale" in
 Xja|Xja_JP|Xja_JP.*)
    ext=ja
    ;;
 *)
    ext=en
    ;;
esac

[ -x ${bindir}/w3m-${ext} ] && w3m_bin=${bindir}/w3m-${ext}
[ -f ${http_home_dir}/index.html.${locale} ] && \
	http_home=${http_home_dir}/index.html.${locale}


## open http_home when empty URL is given for
if [ -f $http_home ]; then
  [ -z "$*" ] && exec $w3m_bin $http_home
fi

exec $w3m_bin "$@"
