1#!/bin/sh 2# Emulate nroff with groff.
| 1#!/bin/sh 2# Emulate nroff with groff.
|
3# $FreeBSD: head/contrib/groff/src/roff/nroff/nroff.sh 55844 2000-01-12 10:26:36Z asmodai $
| 3# $FreeBSD: head/contrib/groff/src/roff/nroff/nroff.sh 69631 2000-12-05 19:06:41Z ru $
|
4 5prog="$0" 6# Default device.
| 4 5prog="$0" 6# Default device.
|
7locale=${LC_CTYPE:-$LANG} 8if test `expr "$locale" : ".*\.ISO_8859-1"` -gt 0 9then 10 T=-Tlatin1 11else 12if test `expr "$locale" : ".*\.KOI8-R"` -gt 0 13then 14 T=-Tkoi8-r 15else 16 T=-Tascii 17fi 18fi
| 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 "`#locale charmap 2>/dev/null`" in 10 UTF-8) 11 T=-Tutf8 ;; 12 ISO-8859-1) 13 T=-Tlatin1 ;; 14 IBM-1047) 15 T=-Tcp1047 ;; 16 *) 17 case "${LC_ALL-${LC_CTYPE-${LANG}}}" in 18 *.UTF-8) 19 T=-Tutf8 ;; 20 iso_8859_1 | *.ISO-8859-1 | *.ISO_8859-1) 21 T=-Tlatin1 ;; 22 *.IBM-1047) 23 T=-Tcp1047 ;; 24 *.KOI8-R) 25 T=-Tkoi8-r ;; 26 *) 27 case "$LESSCHARSET" in 28 utf-8) 29 T=-Tutf8 ;; 30 latin1) 31 T=-Tlatin1 ;; 32 cp1047) 33 T=-Tcp1047 ;; 34 *) 35 T=-Tascii ;; 36 esac ;; 37 esac ;; 38esac
|
19opts= 20safer=-S 21
| 39opts= 40safer=-S 41
|
22for i 23do 24 case $1 in 25 -h) 26 opts="$opts -P-h" 27 ;; 28 -[eq]|-s*) 29 # ignore these options 30 ;; 31 -[mrnoT]) 32 echo "$prog: option $1 requires an argument" >&2 33 exit 1 34 ;; 35 -[iStp]|-[mrno]*) 36 opts="$opts $1"; 37 ;;
| 42# `for i; do' doesn't work with some versions of sh
|
38
| 43
|
39 -Tascii|-Tlatin1|-Tkoi8-r) 40 T=$1 41 ;; 42 -T*) 43 # ignore other devices 44 ;; 45 -S) 46 # safer behaviour 47 safer=-S 48 ;; 49 -U) 50 # unsafe behaviour 51 safer=-U 52 ;; 53 -u*) 54 # Solaris 2.2 `man' uses -u0; ignore it, 55 # since `less' and `more' can use the emboldening info. 56 ;; 57 --) 58 shift 59 break 60 ;; 61 -) 62 break 63 ;; 64 -*) 65 echo "$prog: invalid option $1" >&2 66 exit 1 67 ;; 68 *) 69 break 70 ;; 71 esac 72 shift
| 44for i 45 do 46 case $1 in 47 -h) 48 opts="$opts -P-h" ;; 49 -[eq] | -s*) 50 # ignore these options 51 ;; 52 -[mrnoT]) 53 echo "$prog: option $1 requires an argument" >&2 54 exit 1 ;; 55 -[itp] | -[mrno]*) 56 opts="$opts $1" ;; 57 -Tascii | -Tlatin1 | -Tkoi8-r | -Tutf8 | -Tcp1047) 58 T=$1 ;; 59 -T*) 60 # ignore other devices 61 ;; 62 -S) 63 # safer behaviour 64 safer=-S ;; 65 -U) 66 # unsafe behaviour 67 safer=-U ;; 68 -u*) 69 # Solaris 2.2 `man' uses -u0; ignore it, 70 # since `less' and `more' can use the emboldening info. 71 ;; 72 --) 73 shift 74 break ;; 75 -) 76 break ;; 77 -*) 78 echo "$prog: invalid option $1" >&2 79 exit 1 ;; 80 *) 81 break ;; 82 esac 83 shift
|
73done 74 75# This shell script is intended for use with man, so warnings are 76# probably not wanted. Also load nroff-style character definitions. 77exec groff $safer -Wall -mtty-char $T $opts ${1+"$@"}
| 84done 85 86# This shell script is intended for use with man, so warnings are 87# probably not wanted. Also load nroff-style character definitions. 88exec groff $safer -Wall -mtty-char $T $opts ${1+"$@"}
|