home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / usr / bin / nroff < prev    next >
Encoding:
Text File  |  2006-06-19  |  2.0 KB  |  98 lines

  1. #!/bin/sh
  2. # Emulate nroff with groff.
  3.  
  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 ;;
  15.   EUC-JP)
  16.     T=-Tnippon ;;
  17.   *)
  18.     case "${LC_ALL-${LC_CTYPE-${LANG}}}" in
  19.       *.UTF-8)
  20.         T=-Tutf8 ;;
  21.       iso_8859_1 | *.ISO-8859-1)
  22.         T=-Tlatin1 ;;
  23.       *.IBM-1047)
  24.         T=-Tcp1047 ;;
  25.       ja_JP.ujis | ja_JP.eucJP)
  26.     T=-Tnippon ;;
  27.       *)
  28.         case "$LESSCHARSET" in
  29.           utf-8)
  30.             T=-Tutf8 ;;
  31.           latin1)
  32.             T=-Tlatin1 ;;
  33.           cp1047)
  34.             T=-Tcp1047 ;;
  35.           japanese)
  36.         T=-Tnippon ;;
  37.           *)
  38.             T=-Tascii8 ;;
  39.           esac ;;
  40.      esac ;;
  41. esac
  42. opts=
  43.  
  44. # `for i; do' doesn't work with some versions of sh
  45.  
  46. for i
  47.   do
  48.   case $1 in
  49.     -c)
  50.       opts="$opts -P-c" ;;
  51.     -h)
  52.       opts="$opts -P-h" ;;
  53.     -[eq] | -s*)
  54.       # ignore these options
  55.       ;;
  56.     -[mrnoT])
  57.       echo "$prog: option $1 requires an argument" >&2
  58.       exit 1 ;;
  59.     -[iptSUC] | -[mrno]*)
  60.       opts="$opts $1" ;;
  61.     -Tascii | -Tlatin1 | -Tutf8 | -Tcp1047 | -Tascii8 | -Tnippon)
  62.       T=$1 ;;
  63.     -T*)
  64.       # ignore other devices
  65.       ;;
  66.     -u*)
  67.       # Solaris 2.2 `man' uses -u0; ignore it,
  68.       # since `less' and `more' can use the emboldening info.
  69.       ;;
  70.     -v | --version)
  71.       echo "GNU nroff (groff) version 1.18.1"
  72.       exit 0 ;;
  73.     --help)
  74.       echo "usage: nroff [-cChipt] [-mNAME] [-nNUM] [-oLIST] [-rCN] [-Tname] [FILE...]"
  75.       exit 0 ;;
  76.     --)
  77.       shift
  78.       break ;;
  79.     -)
  80.       break ;;
  81.     -*)
  82.       echo "$prog: invalid option $1" >&2
  83.       exit 1 ;;
  84.     *)
  85.       break ;;
  86.   esac
  87.   shift
  88. done
  89.  
  90. # This shell script is intended for use with man, so warnings are
  91. # probably not wanted.  Also load nroff-style character definitions.
  92.  
  93. : ${GROFF_BIN_PATH=/usr/bin}
  94. export GROFF_BIN_PATH
  95. PATH=$GROFF_BIN_PATH:$PATH groff -mtty-char $T $opts ${1+"$@"}
  96.  
  97. # eof
  98.