* src/devices/grotty/grotty.man: Add cp1047 device.
[s-roff.git] / src / roff / nroff / nroff.sh
blob095c047b67bca502d9dc875d94dab49312a48566
1 #!/bin/sh
2 # Emulate nroff with groff.
4 prog="$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.
8 case "`locale charmap 2>/dev/null`" in
9 UTF-8)
10 T=-Tutf8 ;;
11 ISO-8859-1)
12 T=-Tlatin1 ;;
13 IBM-1047)
14 T=-Tcp1047 ;;
16 case "${LC_ALL-${LC_CTYPE-${LANG}}}" in
17 *.UTF-8)
18 T=-Tutf8 ;;
19 iso_8859_1 | *.ISO-8859-1)
20 T=-Tlatin1 ;;
21 *.IBM-1047)
22 T=-Tcp1047 ;;
24 case "$LESSCHARSET" in
25 utf-8)
26 T=-Tutf8 ;;
27 latin1)
28 T=-Tlatin1 ;;
29 cp1047)
30 T=-Tcp1047 ;;
32 T=-Tascii ;;
33 esac ;;
34 esac ;;
35 esac
36 opts=
37 safer=-S
39 for i; do
40 case $1 in
41 -h)
42 opts="$opts -P-h" ;;
43 -[eq] | -s*)
44 # ignore these options
46 -[mrnoT])
47 echo "$prog: option $1 requires an argument" >&2
48 exit 1 ;;
49 -i | -[mrno]*)
50 opts="$opts $1" ;;
51 -Tascii | -Tlatin1 | -Tutf8 | -Tcp1047)
52 T=$1 ;;
53 -T*)
54 # ignore other devices
56 -S)
57 # safer behaviour
58 safer=-S ;;
59 -U)
60 # unsafe behaviour
61 safer=-U ;;
62 -u*)
63 # Solaris 2.2 `man' uses -u0; ignore it,
64 # since `less' and `more' can use the emboldening info.
66 --)
67 shift
68 break ;;
70 break ;;
71 -*)
72 echo "$prog: invalid option $1" >&2
73 exit 1 ;;
75 break ;;
76 esac
77 shift
78 done
80 # This shell script is intended for use with man, so warnings are
81 # probably not wanted. Also load nroff-style character definitions.
82 exec groff $safer -Wall -mtty-char $T $opts ${1+"$@"}