]> git.pld-linux.org Git - packages/groff.git/blob - groff-nroff
- updated to 1.22.4
[packages/groff.git] / groff-nroff
1 #!/bin/sh
2 # Emulate nroff with groff.
3
4 prog="$0"
5 charset_in=iso-8859-1
6 charset_out=`locale charmap 2>/dev/null`
7 opts=
8
9 for i
10 do
11   case $1 in
12     -c)
13       opts="$opts -P-c" ;;
14     -h)
15       opts="$opts -P-h" ;;
16     -[eq] | -s* | -u* | -T* )
17       # ignore these options
18       ;;
19     -[mrnoT])
20       echo "option $1 requires an argument" >&2
21       exit 1 ;;
22     -[iptSUC] | -[mrno]*)
23       opts="$opts $1" ;;
24     -v | --version)
25       echo "GNU nroff (groff) with Red Hat i18n/l10n support"
26       exit 0 ;;
27     --legacy)
28       shift
29       charset_in=$1 ;;
30     --help)
31       echo "usage: $prog [-cChipt] [-mNAME] [-nNUM] [--legacy CHARSET] [-oLIST] [-rCN] [FILE...]"
32       exit 0 ;;
33     --)
34       shift
35       break ;;
36     -)
37       break ;;
38     -*)
39       echo "$prog: invalid option $1" >&2
40       exit 1 ;;
41     *)
42       break ;;
43   esac
44   shift
45 done
46
47 TMPFILE=$(mktemp /tmp/man.XXXXXX)
48 trap "rm -f $TMPFILE" 0 1 2 3 15
49
50 cat ${1+"$@"} >| ${TMPFILE}
51
52 if iconv -f utf-8 -t utf-8 -o /dev/null ${TMPFILE} 2>/dev/null
53 then
54   charset_in=utf-8  
55 fi
56
57 # en_US is chosen arbitrarily; any UTF-8 locale should work
58 LC_ALL=en_US.UTF-8
59 export LC_ALL
60
61 # This shell script is intended for use with man, so warnings are
62 # probably not wanted.  Also load nroff-style character definitions.
63
64 /usr/bin/iconv -f ${charset_in} -t utf-8 ${TMPFILE} | \
65     /usr/bin/groff -mtty-char -Tutf8 $opts 2>/dev/null | \
66     /usr/bin/iconv -f utf-8 -t ${charset_out}//translit
67
68 rm -f ${TMPFILE}
69
70 # eof
This page took 0.050723 seconds and 3 git commands to generate.