* src/preproc/eqn/neqn.sh, src/roff/nroff/nroff.sh: Use
[s-roff.git] / src / roff / nroff / nroff.sh
blob39268f7f6b60679d2768286e02c4aa7781853eb8
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=
38 # `for i; do' doesn't work with some versions of sh
40 for i
42 case $1 in
43 -c)
44 opts="$opts -P-c" ;;
45 -h)
46 opts="$opts -P-h" ;;
47 -[eq] | -s*)
48 # ignore these options
50 -[mrnoT])
51 echo "$prog: option $1 requires an argument" >&2
52 exit 1 ;;
53 -[iptSUC] | -[mrno]*)
54 opts="$opts $1" ;;
55 -Tascii | -Tlatin1 | -Tutf8 | -Tcp1047)
56 T=$1 ;;
57 -T*)
58 # ignore other devices
60 -u*)
61 # Solaris 2.2 `man' uses -u0; ignore it,
62 # since `less' and `more' can use the emboldening info.
64 -v | --version)
65 echo "GNU nroff (groff) version @VERSION@"
66 exit 0 ;;
67 --help)
68 echo "usage: nroff [-CchipStUv] [-mNAME] [-nNUM] [-oLIST] [-rCN] [-Tname] [FILE...]"
69 exit 0 ;;
70 --)
71 shift
72 break ;;
74 break ;;
75 -*)
76 echo "$prog: invalid option $1" >&2
77 exit 1 ;;
79 break ;;
80 esac
81 shift
82 done
84 # This shell script is intended for use with man, so warnings are
85 # probably not wanted. Also load nroff-style character definitions.
87 : ${GROFF_BIN_PATH=@BINDIR@}
88 export GROFF_BIN_PATH
89 PATH=$GROFF_BIN_PATH@SEP@$PATH groff -mtty-char $T $opts ${1+"$@"}
91 # eof