1#! /bin/sh 2# Emulate nroff with groff. 3 4prog="$0" 5# Default device. 6# First try the "locale charmap" command, because it's most reliable. 7# On systems where it doesn't exist, look at the environment variables. 8case "`exec 2>/dev/null ; locale charmap`" in 9 UTF-8) 10 T=-Tutf8 ;; 11 ISO-8859-1 | ISO-8859-15) 12 T=-Tlatin1 ;; 13 IBM-1047) 14 T=-Tcp1047 ;; 15 *) 16 case "${LC_ALL-${LC_CTYPE-${LANG}}}" in 17 *.UTF-8) 18 T=-Tutf8 ;; 19 iso_8859_1 | *.ISO-8859-1 | *.ISO8859-1 | \ 20 iso_8859_15 | *.ISO-8859-15 | *.ISO8859-15) 21 T=-Tlatin1 ;; 22 *.IBM-1047) 23 T=-Tcp1047 ;; 24 *) 25 case "$LESSCHARSET" in 26 utf-8) 27 T=-Tutf8 ;; 28 latin1) 29 T=-Tlatin1 ;; 30 cp1047) 31 T=-Tcp1047 ;; 32 *) 33 T=-Tascii ;; 34 esac ;; 35 esac ;; 36esac 37opts= 38 39# `for i; do' doesn't work with some versions of sh 40 41for i 42 do 43 case $1 in 44 -c) 45 opts="$opts -P-c" ;; 46 -h) 47 opts="$opts -P-h" ;; 48 -[eq] | -s*) 49 # ignore these options 50 ;; 51 -[dMmrnoT]) 52 echo "$prog: option $1 requires an argument" >&2 53 exit 1 ;; 54 -[iptSUC] | -[dMmrno]*) 55 opts="$opts $1" ;; 56 -Tascii | -Tlatin1 | -Tutf8 | -Tcp1047) 57 T=$1 ;; 58 -T*) 59 # ignore other devices 60 ;; 61 -u*) 62 # Solaris 2.2 through at least Solaris 9 `man' invokes 63 # `nroff -u0 ... | col -x'. Ignore the -u0, 64 # since `less' and `more' can use the emboldening info. 65 # However, disable SGR, since Solaris `col' mishandles it. 66 opts="$opts -P-c" ;; 67 -v | --version) 68 echo "GNU nroff (groff) version @VERSION@" 69 exit 0 ;; 70 --help) 71 echo "usage: nroff [-CchipStUv] [-dCS] [-MDIR] [-mNAME] [-nNUM] [-oLIST]" 72 echo " [-rCN] [-Tname] [FILE...]" 73 exit 0 ;; 74 --) 75 shift 76 break ;; 77 -) 78 break ;; 79 -*) 80 echo "$prog: invalid option $1" >&2 81 exit 1 ;; 82 *) 83 break ;; 84 esac 85 shift 86done 87 88# Set up the `GROFF_BIN_PATH' variable 89# to be exported in the current `GROFF_RUNTIME' environment. 90 91@GROFF_BIN_PATH_SETUP@ 92export GROFF_BIN_PATH 93 94# This shell script is intended for use with man, so warnings are 95# probably not wanted. Also load nroff-style character definitions. 96 97PATH="$GROFF_RUNTIME$PATH" groff -mtty-char $T $opts ${1+"$@"} 98 99# eof 100