#!/bin/sh
#
# Convert info to -man format.
#	- Cameron Simpson <cs@zip.com.au> 01nov2000
#

if [ $# -eq 0 ] 
then
   echo "Usage: info2man info-file"
   exit 1
fi

tmpdir=`mktemp -d /tmp/info2man.XXXXXX` ||
   { echo "Cannot create directory \`$tmpdir'. Aborting." >&2; exit 1; }
trap 'ret=$?; rm -rf $tmpdir && exit $ret' 0
trap '(exit 0); exit' 1 2 13 15
tmpfile=`env TMPDIR="" mktemp -p $tmpdir tmpfile.XXXXXX` ||
   { echo "Cannot create temporary file \`$tmpfile'. Aborting." >&2; exit 1; }

xit=0
info2pod ${1+"$@"} >$tmpfile || xit=1
# stderr tossed because of overzealous warnings
pod2man --lax --center='GNU Info' $tmpfile 2>/dev/null || xit=1
exit $xit
