home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / bin / koi8rxterm < prev    next >
Encoding:
Text File  |  2006-08-04  |  1.7 KB  |  73 lines

  1. #!/bin/sh
  2. # $Id: koi8rxterm 189 2005-06-11 00:04:27Z branden $
  3. # This is a wrapper script to set up xterm with a KOI8-R locale; based on
  4. # uxterm, by Thomas Dickey.
  5.  
  6. program=xterm
  7. locale=`(LC_ALL=C LC_CTYPE=C LANG=C locale >/dev/null) 2>&1`
  8. found=no
  9.  
  10. # Check for -version and -help options, to provide a simple return without
  11. # requiring the program to create a window:
  12. if test $# = 1
  13. then
  14.     case $1 in
  15.     -v|-ver*|-h|-he*)
  16.         $program "$@"
  17.         exit $?
  18.         ;;
  19.     esac
  20. fi
  21.  
  22. # Check environment variables that xterm does, in the same order:
  23. for name in LC_ALL LC_CTYPE LANG
  24. do
  25.     eval 'value=$'$name
  26.     if test -n "$value" ; then
  27.         case $value in
  28.         *.koi8r|*.KOI8R|*.koi8-r|*.KOI8-R)
  29.             found=yes
  30.             ;;
  31.         *.koi8r@*|*.KOI8R@*|*.koi8-r@*|*.KOI8-R*)
  32.             found=yes
  33.             ;;
  34.         C|POSIX)
  35.             # The user may not have configured his or her
  36.             # locale; try to muddle through anyway.
  37.             value=ru_RU.KOI8-R
  38.             ;;
  39.         esac
  40.         break
  41.     fi
  42. done
  43.  
  44. # If we didn't find a locale that uses KOI8-R, modify the safest one.  Not
  45. # everyone has a KOI8-R locale installed (and there appears to be no
  46. # trivial/portable way to determine whether it is, from a shell script).
  47. # We could check if the user's shell does not reset unknown locale
  48. # specifiers, but not all shells do.
  49. if test $found != yes ; then
  50.     if test -n "$value" ; then
  51.         value=`echo ${value} |sed -e 's/[.@].*//'`.KOI8-R
  52.     else
  53.         name="LC_CTYPE"
  54.         value="ru_RU.KOI8-R"
  55.     fi
  56.     eval ${name}=${value}
  57.     eval export ${name}
  58.     if test -z "$locale" ; then
  59.         # The 'locale' program tries to do a sanity check.
  60.         check=`(locale >/dev/null) 2>&1`
  61.         if test -n "$check" ; then
  62.             echo "koi8rxterm tried to use locale $value" >&2
  63.             echo "$check" >&2
  64.             exit 1
  65.         fi
  66.     fi
  67. fi
  68.  
  69. # for testing:
  70. #test -f ./xterm && program=./xterm
  71.  
  72. exec $program -class KOI8RXTerm -title 'koi8rxterm' -k8 "$@"
  73.