Testing terminals with KornShell.


[Home] Home > Blog >
Testing terminals with KornShell.

A simple script to test terminals.

1. Synopsis

I usually use vttest to test my terminals, but this could be considered overkill for some things, and would also probably be a pain to compile for every Unix system I have.

So, I wrote a simple script (originally for AT&T SVR3) to exercise various terminal stuff.

The script itself has two parts. The first part is a screen alignment test (DECALN) that I decided to add for physical terminals (should I get more), and the second part is an exercise of some text attributes.

This won't exercise some of the more advanced things that vttest exercises.

1.1. Note

This will probably need porting if you wish to run it in the GNU Bourne Again shell. This was written using KornShell 88 on AT&T Unix System V Release 3.2.

2. Source

#!/bin/ksh

NORM=$(echo "\033[0m")
BOLD=$(echo "\033[1m")
DIM=$(echo "\033[2m")
UNDL=$(echo "\033[4m")
BLNK=$(echo "\033[5m")

# Ask a 'yes/no' question.
# Returns 1 if the user answers 'yes'; otherwise 'no'.
yesno() {
  typeset input=""

  while true
  do
    print -n "${*} (y/n) "
    read input

    case "${input}" in
      y*) return 1                 ;;
      n*) return 0                 ;;
      *)  echo "Invalid response." ;;
    esac
  done
}

# Place cursor.
# $1 = row
# $2 = column
cup() {
  print -n "\033[${1};${2}H"
}

# Print double height line.
# $1 - row
# $2 - column
# $3 - message
#
# This will use up two lines.
decdhl() {
  let nr="$1+1"

  cup $1  $2; print -n "\033#3${3}"
  cup $nr $2; print -n "\033#4${3}"
  echo
}

# Clear the screen.
clear() {
  print "\033c"
}

# Perform an alignment test, then sleep for a few seconds.
aligntest() {
  let runs=6

  clear
  echo "\033#8"
  cup 1 1
  print -n "Alignment test"

  while true
  do
    test $runs -eq 0 && return 1
    let runs="$runs-1"
    cup 2 1
    print -n "${runs}"
    sleep 1
  done
}

# Should we perform an alignment test?
yesno "Perform alignment test?"
test $? -eq 1 && aligntest

# Let's clear the screen and do the fun stuff!
clear
cat <<EOF
  Your terminal is set as ${TERM}

  ${BOLD}This is bold${NORM}
  ${DIM}This is dim${NORM}
  ${UNDL}This is underline${NORM}
  ${BLNK}This is blinking${NORM}

  ${BOLD}${UNDL}This is bold underline${NORM}
  ${BOLD}${BLNK}This is bold blinking${NORM}
  ${BOLD}${UNDL}${BLNK}This is bold underline blinking${NORM}

  ${DIM}${UNDL}This is dim underline${NORM}
  ${DIM}${BLNK}This is dim blinking${NORM}
  ${DIM}${UNDL}${BLNK}This is dim underline blinking${NORM}

  ${NORM}This is normal${NORM}

  line 1:
  line 2:

EOF

# Do a double height line test.
decdhl 19 11 "Double height line"

# End of vttest.sh

3. Some screenshots

Here's some screenshots containing the results of the script with various terminal emulators.

3.1. Kea! 420

Kea! 420

3.2. PowerTerm 525

This is the version of PowerTerm provided on the Windows 95 / Windows NT version of DEC PATHWORKS.

PowerTerm 525

3.3. PROCOMM PLUS

PROCOMM PLUS

3.4. Reflection 4

Reflection 4

3.5. XVision Eclipse VT420

XVision Eclipse VT420

3.6. XVision VT52

Well, this is probably the best terminal emulator ever :)

XVision VT52

3.7. XVision VT320

So, it turns out that XVision 5.x and 6.x have a VT320 terminal emulator, and it's pretty accurate.

XVision VT320

Return to top


Made with weblorg
Copyright © 2010-2024 Paul Ward.