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