#! /bin/sh
_PROGRAM_VERSION='0.9.22';
_LAST_UPDATE='22 August 2005';
export _PROGRAM_VERSION;
export _LAST_UPDATE;
export GROFFER_OPT;
export _CONF_FILE_ETC; export _CONF_FILE_HOME; export _CONF_FILES; _CONF_FILE_ETC='/etc/groff/groffer.conf';
_CONF_FILE_HOME="${HOME}/.groff/groffer.conf";
_CONF_FILES="${_CONF_FILE_ETC} ${_CONF_FILE_HOME}";
export _AT;
export _SP;
export _SQ;
export _TAB;
_AT='@';
_SP=' ';
_SQ="'";
_TAB=' ';
export _ERROR;
_ERROR='7';
export _GROFF_VERSION
_GROFF_VERSION='@VERSION@';
if test _@VERSION@_ = _${_AT}VERSION${_AT}_
then
_GROFF_VERSION='1.19.2';
fi;
export _AT_BINDIR_AT;
export _AT_G_AT;
export _AT_LIBDIR_AT;
export _GROFFER_LIBDIR;
if test _@BINDIR@_ = _${_AT}BINDIR${_AT}_
then
_AT_BINDIR_AT='.';
_AT_G_AT='';
_AT_LIBDIR_AT='';
_GROFFER_LIBDIR='.';
else
_AT_BINDIR_AT='@BINDIR@';
_AT_G_AT='@g@';
_AT_LIBDIR_AT='@libdir@';
_GROFFER_LIBDIR="${_AT_LIBDIR_AT}"'/groff/groffer';
fi;
export _GROFFER_SH; case "$0" in
*groffer*)
_GROFFER_SH="$0";
;;
*)
echo 'The groffer script should be started directly.' >&2
exit 1;
;;
esac;
export _GROFFER2_SH; _GROFFER2_SH="${_GROFFER_LIBDIR}"/groffer2.sh;
export _NULL_DEV;
if test -c /dev/null
then
_NULL_DEV="/dev/null";
else
_NULL_DEV="NUL";
fi;
if test _"$(echo "$(echo 'test')")"_ \
!= _test_
then
echo 'The "$()" construct did not work.' >&2;
exit "${_ERROR}";
fi;
if test _"$(echo red | sed -e 's/r/s/')"_ != _sed_
then
echo 'The sed program did not work.' >&2;
exit "${_ERROR}";
fi;
for f in "${_CONF_FILE_HOME}" "${_CONF_FILE_ETC}"
do
if test -f "$f"
then
o=""; eval "$(cat "$f" | sed -n -e '
# Ignore comments
/^['"${_SP}${_TAB}"']*#/d
# Delete leading and final space
s/^['"${_SP}${_TAB}"']*//
s/['"${_SP}${_TAB}"']*$//
# Print all shell commands
/^[^-]/p
# Replace empty arguments
s/^\(-[^ ]*\)=$/o="${o} \1 '"${_SQ}${_SQ}"'"/p
# Replace division between option and argument by single space
s/[='"${_SP}${_TAB}"']['"${_SP}${_TAB}"']*/'"${_SP}"'/
# Handle lines without spaces
s/^\(-[^'"${_SP}"']*\)$/o="${o} \1"/p
# Print options that have their argument encircled with single quotes
/^-[^ ]* '"${_SQ}"'.*'"${_SQ}"'$/s/^.*$/o="${o} &"/p
# Replace encircled double quotes by single quotes and print the result
s/^\(-[^ ]*\) "\(.*\)"$/o="${o} \1 '"${_SQ}"'\2'"${_SQ}"'"/p
# Encircle the remaining arguments with single quotes
s/^\(-[^ ]*\) \(.*\)$/o="${o} \1 '"${_SQ}"'\2'"${_SQ}"'"/p
')"
if test _"${o}"_ != __
then
if test _"{GROFFER_OPT}"_ = __
then
GROFFER_OPT="${o}";
else
GROFFER_OPT="${o} ${GROFFER_OPT}";
fi;
fi;
fi;
done;
if test _"${GROFFER_OPT}"_ != __
then
eval set x "${GROFFER_OPT}" '"$@"';
shift;
GROFFER_OPT='';
fi;
export _SHELL;
_SHELL=`
export x;
case " $*" in
*\ --sh*) x='';
s='';
while test $ do
case "$1" in
--shell|--sh|--she|--shel)
if test "$#" -ge 2
then
s="$2";
shift;
fi;
;;
--shell=*|--sh=*|--she=*|--shel=*)
s="$(echo x"$1" | sed -e 's/^x[^=]*=//')";
;;
*)
shift;
continue;
esac;
if test _"${x}"_ = __
then
x="'${s}'";
else
x="'${s}' ${x}";
fi;
shift;
done;
s="$(
# "" quotes because of posh
eval set x "${x}";
shift;
if test $# != 0
then
for i
do
if test _"$i"_ = __
then
# use the empty argument as the default shell
echo empty;
break;
else
# test $i on being a shell program;
# use this kind of quoting for posh
if test _"$(eval "$i -c 'echo ok'" 2>${_NULL_DEV})"_ = _ok_ >&2
then
# shell found
cat <<EOF
${i}
EOF
break;
else
# if not being a shell go on searching
continue;
fi;
fi;
done;
fi;
)";
if test _"${s}"_ != __
then
cat <<EOF
${s}
EOF
fi;
;;
esac;
`
if test _"${_SHELL}"_ = __
then
for s in ksh ash dash pdksh zsh posh
do
if test _"$(eval "$s -c 'echo ok'" 2>${_NULL_DEV})"_ = _ok_ >&2
then
_SHELL="$s";
break;
fi;
done;
fi;
if test _"${_SHELL}"_ = _empty_
then
_SHELL='';
fi;
if test _"${_SHELL}"_ = __
then
eval exec "'${_GROFFER2_SH}'" '"$@"';
exit;
else
eval exec "${_SHELL} '${_GROFFER2_SH}'" '"$@"';
exit;
fi;