Get rid of the old texinfo.
[dragonfly.git] / contrib / groff / src / roff / nroff / nroff.sh
1 #!/bin/sh
2 # Emulate nroff with groff.
3 # $FreeBSD: src/contrib/groff/src/roff/nroff/nroff.sh,v 1.11.2.3 2003/02/14 15:22:08 ru Exp $
4 # $DragonFly: src/contrib/groff/src/roff/nroff/Attic/nroff.sh,v 1.2 2003/06/17 04:24:02 dillon Exp $
5
6 prog="$0"
7 # Default device.
8 # First try the "locale charmap" command, because it's most reliable.
9 # On systems where it doesn't exist, look at the environment variables.
10 case "`#locale charmap 2>/dev/null`" in
11   UTF-8)
12     T=-Tutf8 ;;
13   ISO-8859-1)
14     T=-Tlatin1 ;;
15   IBM-1047)
16     T=-Tcp1047 ;;
17   *)
18     case "${LC_ALL-${LC_CTYPE-${LANG}}}" in
19       *.UTF-8)
20         T=-Tutf8 ;;
21       iso_8859_1 | *.ISO*8859-1 | *.ISO*8859-15)
22         T=-Tlatin1 ;;
23       *.IBM-1047)
24         T=-Tcp1047 ;;
25       *.KOI8-R)
26         T=-Tkoi8-r ;;
27       *)
28         case "$LESSCHARSET" in
29           utf-8)
30             T=-Tutf8 ;;
31           latin1)
32             T=-Tlatin1 ;;
33           cp1047)
34             T=-Tcp1047 ;;
35           *)
36             T=-Tascii ;;
37           esac ;;
38      esac ;;
39 esac
40 opts=
41
42 # `for i; do' doesn't work with some versions of sh
43
44 for i
45   do
46   case $1 in
47     -c)
48       opts="$opts -P-c" ;;
49     -h)
50       opts="$opts -P-h" ;;
51     -[eq] | -s*)
52       # ignore these options
53       ;;
54     -[mrnoT])
55       echo "$prog: option $1 requires an argument" >&2
56       exit 1 ;;
57     -[iptSUC] | -[mrno]*)
58       opts="$opts $1" ;;
59     -Tascii | -Tlatin1 | -Tkoi8-r | -Tutf8 | -Tcp1047)
60       T=$1 ;;
61     -T*)
62       # ignore other devices
63       ;;
64     -u*)
65       # Solaris 2.2 `man' uses -u0; ignore it,
66       # since `less' and `more' can use the emboldening info.
67       ;;
68     -v | --version)
69       echo "GNU nroff (groff) version @VERSION@"
70       exit 0 ;;
71     --help)
72       echo "usage: nroff [-cChipt] [-mNAME] [-nNUM] [-oLIST] [-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
86 done
87
88 # This shell script is intended for use with man, so warnings are
89 # probably not wanted.  Also load nroff-style character definitions.
90
91 : ${GROFF_BIN_PATH=@BINDIR@}
92 export GROFF_BIN_PATH
93 PATH=$GROFF_BIN_PATH:$PATH groff -mtty-char $T $opts ${1+"$@"}
94
95 # eof