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