No empty .Rs/.Re
[netbsd-mini2440.git] / gnu / dist / groff / src / roff / nroff / nroff.sh
blob3120215534f7d10003306288a47c341d92ae4fd9
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 "`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 ;;
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 ;;
25 case "$LESSCHARSET" in
26 utf-8)
27 T=-Tutf8 ;;
28 latin1)
29 T=-Tlatin1 ;;
30 cp1047)
31 T=-Tcp1047 ;;
33 T=-Tascii ;;
34 esac ;;
35 esac ;;
36 esac
37 opts=
39 # `for i; do' doesn't work with some versions of sh
41 for i
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
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
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 ;;
78 break ;;
79 -*)
80 echo "$prog: invalid option $1" >&2
81 exit 1 ;;
83 break ;;
84 esac
85 shift
86 done
88 # Set up the `GROFF_BIN_PATH' variable
89 # to be exported in the current `GROFF_RUNTIME' environment.
91 @GROFF_BIN_PATH_SETUP@
92 export GROFF_BIN_PATH
94 # This shell script is intended for use with man, so warnings are
95 # probably not wanted. Also load nroff-style character definitions.
97 PATH="$GROFF_RUNTIME$PATH" groff -mtty-char $T $opts ${1+"$@"}
99 # eof