aboutsummaryrefslogtreecommitdiff
path: root/contrib/groff/src/roff/nroff/nroff.sh
blob: 82f9031cd8c59c08afea4f915ce12218c83aede1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/bin/sh
# Emulate nroff with groff.
# $FreeBSD$

prog="$0"
# Default device.
# First try the "locale charmap" command, because it's most reliable.
# On systems where it doesn't exist, look at the environment variables.
case "`#locale charmap 2>/dev/null`" in
  UTF-8)
    T=-Tutf8 ;;
  ISO-8859-1)
    T=-Tlatin1 ;;
  IBM-1047)
    T=-Tcp1047 ;;
  *)
    case "${LC_ALL-${LC_CTYPE-${LANG}}}" in
      *.UTF-8)
        T=-Tutf8 ;;
      iso_8859_1 | *.ISO*8859-1 | *.ISO*8859-15)
        T=-Tlatin1 ;;
      *.IBM-1047)
        T=-Tcp1047 ;;
      *.KOI8-R)
        T=-Tkoi8-r ;;
      *)
        case "$LESSCHARSET" in
          utf-8)
            T=-Tutf8 ;;
          latin1)
            T=-Tlatin1 ;;
          cp1047)
            T=-Tcp1047 ;;
          *)
            T=-Tascii ;;
          esac ;;
     esac ;;
esac
opts=
safer=-S

# `for i; do' doesn't work with some versions of sh

for i
  do
  case $1 in
    -h)
      opts="$opts -P-h" ;;
    -[eq] | -s*)
      # ignore these options
      ;;
    -[mrnoT])
      echo "$prog: option $1 requires an argument" >&2
      exit 1 ;;
    -[ipt] | -[mrno]*)
      opts="$opts $1" ;;
    -Tascii | -Tlatin1 | -Tkoi8-r | -Tutf8 | -Tcp1047)
      T=$1 ;;
    -T*)
      # ignore other devices
      ;;
    -S)
      # safer behaviour
      safer=-S ;;
    -U)
      # unsafe behaviour
      safer=-U ;;
    -u*)
      # Solaris 2.2 `man' uses -u0; ignore it,
      # since `less' and `more' can use the emboldening info.
      ;;
    -v | --version)
      echo "GNU nroff (groff) version @VERSION@"
      exit 0 ;;
    --help)
      echo "usage: nroff [-h] [-i] [-mNAME] [-nNUM] [-oLIST] [-p] [-rCN] [-t] [-Tname] [FILE...]"
      exit 0 ;;
    --)
      shift
      break ;;
    -)
      break ;;
    -*)
      echo "$prog: invalid option $1" >&2
      exit 1 ;;
    *)
      break ;;
  esac
  shift
done

# This shell script is intended for use with man, so warnings are
# probably not wanted.  Also load nroff-style character definitions.

: ${GROFF_BIN_PATH=@BINDIR@}
export GROFF_BIN_PATH
PATH=$GROFF_BIN_PATH:$PATH groff $safer -Wall -mtty-char $T $opts ${1+"$@"}

# eof