home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume4 / gnumacs-blit / part01 / 5620m / 5620mtset < prev    next >
Text File  |  1989-02-03  |  2KB  |  81 lines

  1. #!/bin/sh
  2. #    5620mtset Gernot Heiser (heiser@iis.uucp) 1988-07-16
  3. #
  4. # This program writes to the standard output the commands required to
  5. # correctly set the terminal environment in a 5620m layer. The program
  6. # should therefore be installed on all machines, not only the ones
  7. # where mux is installed.
  8. #
  9. # The normal (interactive) use, e.g. to set TERMCAP after an rlogin,
  10. # is
  11. #    eval `5620mtset`
  12. # Note that csh users must
  13. #    set noglob
  14. # first.
  15. #
  16. # The -f option is used by 5620m to initially setup the terminal in
  17. # the layer. It causes the terminal to be reverted from a funny mux
  18. # state to usual settings (echo, crt). The latter is done by the
  19. # program `5620mstty'. Note that the -f option is only needed for
  20. # initial setup, therefore `5620mstty' needs only to be installed
  21. # where mux is installed.
  22. #
  23. # The -c and -s options force the commands to be in /bin/csh or
  24. # /bin/sh format respectively. This is useful in shell scripts
  25. # executed by a shell other than the user's default shell.
  26. #
  27. # Warning: This program is rather tricky and, after lots of trial and
  28. # error, appears to be working now. Don't change it, unless you are
  29. # sure to know what you are doing!!!
  30. #
  31.  
  32. export SHELL
  33. fixtty=no
  34.  
  35. while true; do
  36.    case $1 in
  37.    -c)    SHELL=/bin/csh
  38.     shift;;
  39.    -f)  fixtty=yes
  40.     shift;;
  41.    -s)    SHELL=/bin/sh
  42.     shift;;
  43.    *)    break;;
  44.    esac
  45. done
  46.  
  47. if [ $# != 0 ]; then
  48.    echo usage: eval \`$0 [-c -e -f -s]\` 1>&2
  49.    exit 1
  50. fi
  51.  
  52. if [ $fixtty != "yes" ]; then
  53.    stty -echo > /dev/tty
  54. fi
  55.  
  56. echo -n "[?C" > /dev/tty
  57. cmd=
  58. read temp
  59. while true; do
  60.     case $temp in
  61.         \[\?[0-9]*\;[0-9]*C)
  62.             break;;
  63.         *)
  64.             cmd="${cmd};$temp"
  65.             read temp ;;
  66.     esac
  67. done
  68.  
  69. size="`echo $temp | \
  70.     sed -e 's/\[?\([0-9][0-9]*\);\([0-9][0-9]*\)C/co#\2:li#\1/`"
  71.  
  72. tset -s -Q 5620x | sed -e "s/co#[0-9][0-9]*:li#[0-9][0-9]*/${size}/"
  73. if [ "$cmd" != "" ]; then
  74.    echo "$cmd"
  75. fi
  76.  
  77. if [ $fixtty = "yes" ]; then
  78.    5620mstty
  79. fi
  80. stty echo crt > /dev/tty
  81.