xref: /openbsd/usr.bin/tset/tset.1 (revision 81d8c4e1)
1.\"	$OpenBSD: tset.1,v 1.17 2010/01/12 23:22:14 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: January 12 2010 $
33.Dt TSET 1
34.Os
35.Sh NAME
36.Nm tset
37.Nd terminal initialization
38.Sh SYNOPSIS
39.Nm tset
40.Op Fl cIQqrSsVw
41.Op Fl
42.Op Fl e Ar ch
43.Op Fl i Ar ch
44.Op Fl k Ar ch
45.Op Fl m Ar mapping
46.Op Ar terminal
47.Nm reset
48.Op Fl cIQqrSsVw
49.Op Fl
50.Op Fl e Ar ch
51.Op Fl i Ar ch
52.Op Fl k Ar ch
53.Op Fl m Ar mapping
54.Op Ar terminal
55.Sh DESCRIPTION
56.Nm tset
57initializes terminals.
58.Nm tset
59first determines the type of terminal that you are using.
60This determination is done as follows, using the first terminal type found:
61.Bl -enum -offset indent
62.It
63The
64.Ar terminal
65argument specified on the command line.
66.It
67The value of the
68.Ev TERM
69environment variable.
70.It
71The terminal type associated with the standard error output device in the
72.Pa /etc/ttys
73file.
74.It
75The default terminal type,
76.Dq unknown .
77.El
78.Pp
79If the terminal type was not specified on the command line, the
80.Fl m
81option mappings are then applied (see below for more information).
82Then, if the terminal type begins with a question mark
83.Pq Ql \&? ,
84the user is prompted for confirmation of the terminal type.
85An empty response confirms the type, or another type can be entered to
86specify a new type.
87Once the terminal type has been determined, the termcap entry for the terminal
88is retrieved.
89If no termcap entry is found for the type, the user is prompted for another
90terminal type.
91.Pp
92Once the termcap entry is retrieved, the window size, backspace, interrupt,
93and line kill characters (among many other things) are set and the terminal
94and tab initialization strings are sent to the standard error output.
95Finally, if the erase, interrupt and line kill characters have changed,
96or are not set to their default values, their values are displayed to the
97standard error output.
98Use the
99.Fl c
100or
101.Fl w
102option to select only the window sizing versus the other initialization.
103If neither option is given, both are assumed.
104.Pp
105When invoked as
106.Nm reset ,
107.Nm tset
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 an abnormal state.
112Note, you may have to type
113.Dq <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 Ds
120.It Fl
121The terminal type is displayed to the standard output, and the terminal is
122not initialized in any way.
123This option has been deprecated in favor of the
124.Fl q
125flag.
126.It Fl c
127Set control characters and modes.
128.It Fl e Ar ch
129Set the erase character to
130.Ar ch .
131.It Fl I
132Do not send the terminal or tab initialization strings to the terminal.
133.It Fl i Ar ch
134Set the interrupt character to
135.Ar ch .
136.It Fl k Ar ch
137Set the line kill character to
138.Ar ch .
139.It Fl m Ar mapping
140Specify a mapping from a port type to a terminal.
141See below for more information.
142.It Fl Q
143Don't display any values for the erase, interrupt and line kill characters.
144Normally
145.Nm
146displays the values for control characters which differ from the system's
147default values.
148.It Fl q
149The terminal type is displayed to the standard output, and the terminal is
150not initialized in any way.
151.It Fl r
152Print the terminal type to the standard error output.
153.It Fl S
154Print the terminal type and the termcap entry to the standard output.
155See the section below on setting the environment for details.
156.It Fl s
157Print the sequence of shell commands to initialize the environment variables
158.Ev TERM
159and
160.Ev TERMCAP
161to the standard output.
162See the section below on setting the environment for details.
163.It Fl V
164Report the version of ncurses which was used in this program, and exit.
165.It Fl w
166Resize the window to match the size deduced via
167.Xr setupterm 3 .
168Normally this has no effect, unless
169.Xr setupterm 3
170is not able to detect the window size.
171.El
172.Pp
173The arguments for the
174.Fl e ,
175.Fl i ,
176and
177.Fl k
178options may either be entered as actual characters or by using the
179.Dq hat
180notation, i.e., control-H may be specified as
181.Dq ^H
182or
183.Dq ^h .
184.Sh SETTING THE ENVIRONMENT
185It is often desirable to enter the terminal type and information about
186the terminal's capabilities into the shell's environment.
187This is done using the
188.Fl S
189and
190.Fl s
191options.
192.Pp
193When the
194.Fl S
195option is specified, the terminal type and the termcap entry are written
196to the standard output, separated by a space and without a terminating
197newline.
198This can be assigned to an array by
199.Xr csh 1
200and
201.Xr ksh 1
202users and then used like any other shell array.
203.Pp
204When the
205.Fl s
206option is specified, the commands to enter the information into the
207shell's environment are written to the standard output.
208If the
209.Ev SHELL
210environment variable ends in
211.Dq csh ,
212the commands are for
213.Xr csh 1 ,
214otherwise, they are for
215.Xr sh 1 .
216Note, the
217.Xr csh 1
218commands set and unset the shell variable
219.Dq noglob ,
220leaving it unset.
221The following line in the
222.Pa .login
223or
224.Pa .profile
225files will initialize the environment correctly:
226.Bd -literal -offset indent
227eval \`tset -s options ... \`
228.Ed
229.Pp
230To demonstrate a simple use of the
231.Fl S
232option, the following lines in the
233.Pa .login
234file have an equivalent effect:
235.Bd -literal -offset indent
236set noglob
237set term=(`tset -S options ...`)
238setenv TERM $term[1]
239setenv TERMCAP "$term[2]"
240unset term
241unset noglob
242.Ed
243.Sh TERMINAL TYPE MAPPING
244When the terminal is not hardwired into the system (or the current system
245information is incorrect), the terminal type derived from the
246.Pa /etc/ttys
247file or the
248.Ev TERM
249environment variable is often something generic like
250.Dq network ,
251.Dq dialup ,
252or
253.Dq unknown .
254When
255.Nm tset
256is used in a startup script
257.Pf ( Pa .profile
258for
259.Xr sh 1
260users or
261.Pa .login
262for
263.Xr csh 1
264users) it is often desirable to provide information about the type of
265terminal used on such ports.
266.Pp
267The purpose of the
268.Fl m
269option is to
270.Dq map
271from some set of conditions to a terminal type, that is, to
272tell
273.Nm tset
274``If I'm on this port at a particular speed, guess that I'm on that
275kind of terminal''.
276.Pp
277The argument to the
278.Fl m
279option consists of an optional port type, an optional operator, an optional
280baud rate specification, an optional colon
281.Pq Ql \&:
282character, and a terminal type.
283The port type is a string (delimited by either the operator or the colon
284character).
285The operator may be any combination of:
286.Ql > ,
287.Ql < ,
288.Ql @ ,
289and
290.Ql \&! ;
291.Ql >
292means greater than,
293.Ql <
294means less than,
295.Ql @
296means equal to,
297and
298.Ql \&!
299inverts the sense of the test.
300The baud rate is specified as a number and is compared with the speed
301of the standard error output (which should be the control terminal).
302The terminal type is a string.
303.Pp
304If the terminal type is not specified on the command line, the
305.Fl m
306mappings are applied to the terminal type.
307If the port type and baud rate match the mapping, the terminal type specified
308in the mapping replaces the current type.
309If more than one mapping is specified, the first applicable mapping is used.
310.Pp
311For example, consider the following mapping:
312.Dq dialup>9600:vt100 .
313The port type is
314.Dq dialup ,
315the operator is
316.Dq > ,
317the baud rate specification is
318.Dq 9600 ,
319and the terminal type is
320.Dq vt100 .
321The result of this mapping is to specify that if the terminal type is
322.Dq dialup ,
323and the baud rate is greater than 9600 baud, a terminal type of
324.Dq vt100
325will be used.
326.Pp
327If no port type is specified, the terminal type will match any port type,
328for example,
329.Dq -m dialup:vt100 -m :?xterm
330will cause any dialup port, regardless of baud rate, to match the terminal
331type
332.Dq vt100 ,
333and any non-dialup port type to match the terminal type
334.Dq ?xterm .
335Note, because of the leading question mark, the user will be
336queried on a default port as to whether they are actually using an
337.Ar xterm
338terminal.
339.Pp
340No whitespace characters are permitted in the
341.Fl m
342option argument.
343Also, to avoid problems with meta-characters, it is suggested that the entire
344.Fl m
345option argument be placed within single quote characters, and that
346.Xr csh 1
347users insert a backslash character
348.Pq Ql \e
349before any exclamation marks
350.Pq Ql \&! .
351.Sh ENVIRONMENT
352The
353.Nm tset
354command utilizes the
355.Ev SHELL
356and
357.Ev TERM
358environment variables.
359.Sh FILES
360.Bl -tag -width /usr/share/misc/termcap -compact
361.It Pa /etc/ttys
362port name to terminal type mapping database
363.It Pa /usr/share/misc/termcap
364terminal capability database
365.El
366.Sh SEE ALSO
367.Xr csh 1 ,
368.Xr sh 1 ,
369.Xr stty 1 ,
370.Xr tty 4 ,
371.Xr termcap 5 ,
372.Xr ttys 5 ,
373.Xr environ 7
374.Sh STANDARDS
375The
376.Nm tset
377command now uses the
378.Xr terminfo 5
379database where previous versions used
380.Xr termcap 5 .
381To make the
382.Fl s
383and
384.Fl S
385options still work,
386.Nm tset
387also reads in the terminal entry from
388.Xr termcap 5 .
389However, this info is used for setting
390.Ev TERMCAP
391only.
392If the terminal type appears in
393.Xr terminfo 5
394but not in
395.Xr termcap 5 ,
396the
397.Fl q
398option will not set
399.Ev TERMCAP
400and the
401.Fl Q
402option will not work at all.
403.Pp
404The
405.Fl A ,
406.Fl E ,
407.Fl h ,
408.Fl u ,
409and
410.Fl v
411options have been deleted from the
412.Nm tset
413utility.
414None of them were documented in
415.Bx 4.3
416and all are of limited utility at best.
417The
418.Fl a ,
419.Fl d
420and
421.Fl p
422options are similarly not documented or useful, but were retained as they
423appear to be in widespread use.
424It is strongly recommended that any usage of these three options be
425changed to use the
426.Fl m
427option instead.
428The
429.Fl n
430option remains, but has no effect.
431It is still permissible to specify the
432.Fl e ,
433.Fl i
434and
435.Fl k
436options without arguments, although it is strongly recommended that such
437usage be fixed to explicitly specify the character.
438.Pp
439Executing
440.Nm tset
441as
442.Nm reset
443no longer implies the
444.Fl Q
445option.
446Also, the interaction between the
447.Fl
448option and the
449.Ar terminal
450argument in some historic implementations of
451.Nm tset
452has been removed.
453.Pp
454Finally, the
455.Nm tset
456implementation has been completely redone (as part of the addition to the
457system of a
458.St -p1003.1-88
459compliant terminal interface) and will no longer compile on systems with
460older terminal interfaces.
461.Sh HISTORY
462The
463.Nm tset
464command appeared in
465.Bx 3.0 .
466