3B2 and 'tset' (the answer)

Tony L. Hansen hansen at pegasus.UUCP
Fri Sep 20 13:56:38 AEST 1985


< Back in the good(?) old days of System III and Version 7 there was a
< terminal initialization program called 'tset'.  Even though this is still
< referenced in the 3B2 documentation in TERMINFO(4) I can find neither hide
< nor hair of it.  If anyone has implemented the equivalent function or knows
< of one I would very much appreciate hearing about it.

[I've cross-posted this to net.unix and net.unix-wizards because a similar
question was posted in those newsgroups a couple of months ago and I never
got around to replying to the question back then.]

The tset program, created by Eric Allman at Berkeley, has several major
functions:

    1) determine the terminal type for setting $TERM,
    2) initialize the terminal for screen-oriented programs,
    3) initialize the carriage-return and newline delays in the tty driver,
    4) set the erase/kill/interrupt characters,
    5) initialize $TERMCAP, and,
    6) reinitializing (resetting) the terminal.

Number 5, setting $TERMCAP, is obviously not needed anymore with terminfo.
Using the compiled terminfo entry is still faster than interpreting from the
$TERMCAP variable.

Number 4, setting ^H, etc., is handled just fine by stty.

Personally I believe that number 1, setting $TERM, belongs in a separate
program from the program that does numbers 2 and 3. A simple invocation of
such a program, call it "getterm", would be:

	TERM=`getterm`; export TERM
or
	setenv TERM `getterm`

Of course, this program should do everything that tset used to do: looking
in a database of hardwired lines and looking at your tty speed, then
assuming or asking questions based on what it found.

Number 2 is the most crucial step, terminal initialization. It is fairly
easy to handle because of a tool provided with Unix System Vr2 called
tput(1). My version of how to do terminal initialization follows. I call
this shell "initterm".

	# initterm - initialize the terminal like tset used to do.
	eval `tput iprog`
	tput is1
	tput is2
	if [ -n "`tput ht`" ]
	then stty tabs; tabs -8
	else stty -tabs
	fi
	cat -s "`tput if`"
	tput is3

Number 3, setting the carriage-return/newline delays, is non-trivial. If a
program were written to do such a thing, it should be done after the above.

Number 6, reset, could be done with very slight modifications to the above
script, such as:

	RS1=`tput rs1`
	if [ -n "$RS1" ]
	then echo "$RS1"
	else tput is1
	fi

for each of the rs1/is1, rs2/is2, rs3/is3 and rf/if pairs.

I hope that all of this helps.

					Tony Hansen
					ihnp4!pegasus!hansen



More information about the Comp.unix.wizards mailing list