xref: /netbsd-src/usr.bin/tset/tset.1 (revision 95d875fb90b1458e4f1de6950286ddcd6644bc61)
1.\"	$NetBSD: tset.1,v 1.9 1999/03/22 18:16:45 garbled Exp $
2.\"
3.\" Copyright (c) 1985, 1990, 1993
4.\"	The Regents of the University of California.  All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\" 3. All advertising materials mentioning features or use of this software
15.\"    must display the following acknowledgement:
16.\"	This product includes software developed by the University of
17.\"	California, Berkeley and its contributors.
18.\" 4. Neither the name of the University nor the names of its contributors
19.\"    may be used to endorse or promote products derived from this software
20.\"    without specific prior written permission.
21.\"
22.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32.\" SUCH DAMAGE.
33.\"
34.\"	@(#)tset.1	8.1 (Berkeley) 6/9/93
35.\"
36.Dd June 9, 1993
37.Dt TSET 1
38.Os
39.Sh NAME
40.Nm tset ,
41.Nm reset
42.Nd terminal initialization
43.Sh SYNOPSIS
44.Nm
45.Op Fl IQrSs
46.Op Fl
47.Op Fl e Ar ch
48.Op Fl i Ar ch
49.Op Fl k Ar ch
50.Op Fl m Ar mapping
51.Op Ar terminal
52.br
53.Nm reset
54.Op Fl IQrSs
55.Op Fl
56.Op Fl e Ar ch
57.Op Fl i Ar ch
58.Op Fl k Ar ch
59.Op Fl m Ar mapping
60.Op Ar terminal
61.Sh DESCRIPTION
62.Nm
63initializes terminals.
64.Nm
65first determines the type of terminal that you are using.
66This determination is done as follows, using the first terminal type found.
67.sp
68.Bl -bullet -compact -offset indent
69.It
70The
71.Ar terminal
72argument specified on the command line.
73.It
74The value of the
75.Ev TERM
76environmental variable.
77.It
78The terminal type associated with the standard error output device in the
79.Pa /etc/ttys
80file.
81.It
82The default terminal type,
83.Dq unknown .
84.El
85.Pp
86If the terminal type was not specified on the command-line, the
87.Fl m
88option mappings are then applied (see below for more information).
89Then, if the terminal type begins with a question mark (``?''), the user is
90prompted for confirmation of the terminal type.
91An empty response confirms the type, or, another type can be entered to
92specify a new type.
93Once the terminal type has been determined, the termcap entry for the terminal
94is retrieved.
95If no termcap entry is found for the type, the user is prompted for another
96terminal type.
97.Pp
98Once the termcap entry is retrieved, the window size, backspace, interrupt
99and line kill characters (among many other things) are set and the terminal
100and tab initialization strings are sent to the standard error output.
101Finally, if the erase, interrupt and line kill characters have changed,
102or are not set to their default values, their values are displayed to the
103standard error output.
104.Pp
105When invoked as
106.Nm reset ,
107.Nm
108sets cooked and echo modes, turns off cbreak and raw modes, turns on
109newline translation and resets any unset special characters to their
110default values before doing the terminal initialization described above.
111This is useful after a program dies leaving a terminal in a abnormal state.
112Note, you may have to type
113.Dq Li <LF>reset<LF>
114(the line-feed character is normally control-J) to get the terminal
115to work, as carriage-return may no longer work in the abnormal state.
116Also, the terminal will often not echo the command.
117.Pp
118The options are as follows:
119.Bl -tag -width flag
120.It Fl
121The terminal type is displayed to the standard output, and the terminal is
122not initialized in any way.
123.It Fl e
124Set the erase character to
125.Ar ch .
126.It Fl I
127Do not send the terminal or tab initialization strings to the terminal.
128.It Fl i
129Set the interrupt character to
130.Ar ch .
131.It Fl k
132Set the line kill character to
133.Ar ch .
134.It Fl m
135Specify a mapping from a port type to a terminal.
136See below for more information.
137.It Fl Q
138Don't display any values for the erase, interrupt and line kill characters.
139.It Fl r
140Print the terminal type to the standard error output.
141.It Fl S
142Print the terminal type and the termcap entry to the standard output.
143See the section below on setting the environment for details.
144.It Fl s
145Print the sequence of shell commands to initialize the environment variables
146.Ev TERM
147and
148.Ev TERMCAP
149to the standard output.
150See the section below on setting the environment for details.
151.El
152.Pp
153The arguments for the
154.Fl e ,
155.Fl i
156and
157.Fl k
158options may either be entered as actual characters or by using the
159.Dq hat
160notation, i.e. control-h may be specified as
161.Dq Li ^H
162or
163.Dq Li ^h .
164.Sh SETTING THE ENVIRONMENT
165It is often desirable to enter the terminal type and information about
166the terminal's capabilities into the shell's environment.
167This is done using the
168.Fl S
169and
170.Fl s
171options.
172.Pp
173When the
174.Fl S
175option is specified, the terminal type and the termcap entry are written
176to the standard output, separated by a space and without a terminating
177newline.
178This can be assigned to an array by
179.Xr csh 1
180and
181.Xr ksh 1
182users and then used like any other shell array.
183.Pp
184When the
185.Fl s
186option is specified, the commands to enter the information into the
187shell's environment are written to the standard output.
188If the
189.Ev SHELL
190environmental variable ends in
191.Dq csh ,
192the commands are for the
193.Xr csh 1 ,
194otherwise, they are for
195.Xr sh 1 .
196Note, the
197.Xr csh 1
198commands
199.Ic set
200and
201.Ic unset
202the shell variable
203.Dq noglob ,
204leaving it unset.
205The following line in the
206.Pa .login
207or
208.Pa .profile
209files will initialize the environment correctly:
210.Bd -literal -offset indent
211eval \`tset -s options ... \`
212.Ed
213.Pp
214To demonstrate a simple use of the
215.Fl S
216option, the following lines in the
217.Pa .login
218file have an equivalent effect:
219.Bd -literal -offset indent
220set noglob
221set term=(`tset -S options ...`)
222setenv TERM $term[1]
223setenv TERMCAP "$term[2]"
224unset term
225unset noglob
226.Ed
227.Sh TERMINAL TYPE MAPPING
228When the terminal is not hardwired into the system (or the current system
229information is incorrect) the terminal type derived from the
230.Pa /etc/ttys
231file or the
232.Ev TERM
233environmental variable is often something generic like
234.Dq network ,
235.Dq dialup ,
236or
237.Dq unknown .
238When
239.Nm
240is used in a startup script
241.Pf ( Pa .profile
242for
243.Xr sh 1
244users or
245.Pa .login
246for
247.Xr csh 1
248users) it is often desirable to provide information about the type of
249terminal used on such ports.
250The purpose of the
251.Fl m
252option is to
253.Dq map
254from some set of conditions to a terminal type, that is, to
255tell
256.Nm
257``If I'm on this port at a particular speed, guess that I'm on that
258kind of terminal''.
259.Pp
260The argument to the
261.Fl m
262option consists of an optional port type, an optional operator, an optional
263baud rate specification, an optional colon (``:'') character and a terminal
264type.
265The port type is a string (delimited by either the operator or the colon
266character).
267The operator may be any combination of:
268.Dq Li \&> ,
269.Dq Li \&< ,
270.Dq Li \&@ ,
271and
272.Dq Li \&! ;
273.Dq Li \&>
274means greater than,
275.Dq Li \&<
276means less than,
277.Dq Li \&@
278means equal to
279and
280.Dq Li \&!
281inverts the sense of the test.
282The baud rate is specified as a number and is compared with the speed
283of the standard error output (which should be the control terminal).
284The terminal type is a string.
285.Pp
286If the terminal type is not specified on the command line, the
287.Fl m
288mappings are applied to the terminal type.
289If the port type and baud rate match the mapping, the terminal type specified
290in the mapping replaces the current type.
291If more than one mapping is specified, the first applicable mapping is used.
292.Pp
293For example, consider the following mapping:
294.Dq Li dialup>9600:vt100 .
295The port type is
296.Dq Li dialup ,
297the operator is
298.Dq Li > ,
299the baud rate specification is
300.Dq Li 9600 ,
301and the terminal type is
302.Dq Li vt100 .
303The result of this mapping is to specify that if the terminal type is
304.Dq Li dialup ,
305and the baud rate is greater than 9600 baud, a terminal type of
306.Dq Li vt100
307will be used.
308.Pp
309If no port type is specified, the terminal type will match any port type,
310for example,
311.Dq Li -m dialup:vt100 -m :?xterm
312will cause any dialup port, regardless of baud rate, to match the terminal
313type
314.Dq Li vt100 ,
315and any non-dialup port type to match the terminal type
316.Dq Li ?xterm .
317Note, because of the leading question mark, the user will be
318queried on a default port as to whether they are actually using an
319.Ar xterm
320terminal.
321.Pp
322No whitespace characters are permitted in the
323.Fl m
324option argument.
325Also, to avoid problems with metacharacters, it is suggested that the entire
326.Fl m
327option argument be placed within single quote characters, and that
328.Xr csh 1
329users insert a backslash character (``\e'') before any exclamation
330marks (``!'').
331.Sh ENVIRONMENT
332The
333.Nm
334command utilizes the
335.Ev SHELL
336and
337.Ev TERM
338environment variables.
339.Sh FILES
340.Bl -tag -width /usr/share/misc/termcap -compact
341.It Pa /etc/ttys
342system port name to terminal type mapping database
343.It Pa /usr/share/misc/termcap
344terminal capability database
345.El
346.Sh SEE ALSO
347.Xr csh 1 ,
348.Xr sh 1 ,
349.Xr stty 1 ,
350.Xr tty 4 ,
351.Xr termcap 5 ,
352.Xr ttys 5 ,
353.Xr environ 7
354.Sh HISTORY
355The
356.Nm
357command appeared in
358.Bx 3.0 .
359.Sh COMPATIBILITY
360The
361.Fl A ,
362.Fl E ,
363.Fl h ,
364.Fl u
365and
366.Fl v
367options have been deleted from the
368.Nm
369utility.
370None of them were documented in
371.Bx 4.3
372and all are of limited utility at
373best.
374The
375.Fl a ,
376.Fl d
377and
378.Fl p
379options are similarly not documented or useful, but were retained as they
380appear to be in widespread use.
381It is strongly recommended that any usage of these three options be
382changed to use the
383.Fl m
384option instead.
385The
386.Fl n
387option remains, but has no effect.
388It is still permissible to specify the
389.Fl e ,
390.Fl i
391and
392.Fl k
393options without arguments, although it is strongly recommended that such
394usage be fixed to explicitly specify the character.
395.Pp
396Executing
397.Nm
398as
399.Nm reset
400no longer implies the
401.Fl Q
402option.
403Also, the interaction between the
404.Fl
405option and the
406.Ar terminal
407argument in some historic implementations of
408.Nm
409has been removed.
410.Pp
411Finally, the
412.Nm
413implementation has been completely redone (as part of the addition to the
414system of a
415.St -p1003.1-88
416compliant terminal interface) and will no longer compile on systems with
417older terminal interfaces.
418