xref: /netbsd/usr.bin/tset/tset.1 (revision c4a72b64)
1.\"	$NetBSD: tset.1,v 1.12 2002/09/30 11:09:14 grant 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 EIQrSs
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 EIQrSs
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 \*[Lt]LF\*[Gt]reset\*[Lt]LF\*[Gt]
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 E
127Emit the extended termcap entry.
128By default the termcap entry is
129truncated to 1024 bytes, this flag specifies the untruncated termcap
130entry is to be output.
131Using this flag may cause problems with some
132shells.
133.It Fl I
134Do not send the terminal or tab initialization strings to the terminal.
135.It Fl i
136Set the interrupt character to
137.Ar ch .
138.It Fl k
139Set the line kill character to
140.Ar ch .
141.It Fl m
142Specify a mapping from a port type to a terminal.
143See below for more information.
144.It Fl Q
145Don't display any values for the erase, interrupt and line kill characters.
146.It Fl r
147Print the terminal type to the standard error output.
148.It Fl S
149Print the terminal type and the termcap entry to the standard output.
150See the section below on setting the environment for details.
151.It Fl s
152Print the sequence of shell commands to initialize the environment variables
153.Ev TERM
154and
155.Ev TERMCAP
156to the standard output.
157See the section below on setting the environment for details.
158.El
159.Pp
160The arguments for the
161.Fl e ,
162.Fl i
163and
164.Fl k
165options may either be entered as actual characters or by using the
166.Dq hat
167notation, i.e. control-h may be specified as
168.Dq Li ^H
169or
170.Dq Li ^h .
171.Sh SETTING THE ENVIRONMENT
172It is often desirable to enter the terminal type and information about
173the terminal's capabilities into the shell's environment.
174This is done using the
175.Fl S
176and
177.Fl s
178options.
179.Pp
180When the
181.Fl S
182option is specified, the terminal type and the termcap entry are written
183to the standard output, separated by a space and without a terminating
184newline.
185This can be assigned to an array by
186.Xr csh 1
187and
188.Xr ksh 1
189users and then used like any other shell array.
190.Pp
191When the
192.Fl s
193option is specified, the commands to enter the information into the
194shell's environment are written to the standard output.
195If the
196.Ev SHELL
197environmental variable ends in
198.Dq csh ,
199the commands are for the
200.Xr csh 1 ,
201otherwise, they are for
202.Xr sh 1 .
203Note, the
204.Xr csh 1
205commands
206.Ic set
207and
208.Ic unset
209the shell variable
210.Dq noglob ,
211leaving it unset.
212The following line in the
213.Pa .login
214or
215.Pa .profile
216files will initialize the environment correctly:
217.Bd -literal -offset indent
218eval \`tset -s options ... \`
219.Ed
220.Pp
221To demonstrate a simple use of the
222.Fl S
223option, the following lines in the
224.Pa .login
225file have an equivalent effect:
226.Bd -literal -offset indent
227set noglob
228set term=(`tset -S options ...`)
229setenv TERM $term[1]
230setenv TERMCAP "$term[2]"
231unset term
232unset noglob
233.Ed
234.Sh TERMINAL TYPE MAPPING
235When the terminal is not hardwired into the system (or the current system
236information is incorrect) the terminal type derived from the
237.Pa /etc/ttys
238file or the
239.Ev TERM
240environmental variable is often something generic like
241.Dq network ,
242.Dq dialup ,
243or
244.Dq unknown .
245When
246.Nm
247is used in a startup script
248.Pf ( Pa .profile
249for
250.Xr sh 1
251users or
252.Pa .login
253for
254.Xr csh 1
255users) it is often desirable to provide information about the type of
256terminal used on such ports.
257The purpose of the
258.Fl m
259option is to
260.Dq map
261from some set of conditions to a terminal type, that is, to
262tell
263.Nm
264``If I'm on this port at a particular speed, guess that I'm on that
265kind of terminal''.
266.Pp
267The argument to the
268.Fl m
269option consists of an optional port type, an optional operator, an optional
270baud rate specification, an optional colon (``:'') character and a terminal
271type.
272The port type is a string (delimited by either the operator or the colon
273character).
274The operator may be any combination of:
275.Dq Li \&\*[Gt] ,
276.Dq Li \&\*[Lt] ,
277.Dq Li \&@ ,
278and
279.Dq Li \&! ;
280.Dq Li \&\*[Gt]
281means greater than,
282.Dq Li \&\*[Lt]
283means less than,
284.Dq Li \&@
285means equal to
286and
287.Dq Li \&!
288inverts the sense of the test.
289The baud rate is specified as a number and is compared with the speed
290of the standard error output (which should be the control terminal).
291The terminal type is a string.
292.Pp
293If the terminal type is not specified on the command line, the
294.Fl m
295mappings are applied to the terminal type.
296If the port type and baud rate match the mapping, the terminal type specified
297in the mapping replaces the current type.
298If more than one mapping is specified, the first applicable mapping is used.
299.Pp
300For example, consider the following mapping:
301.Dq Li dialup\*[Gt]9600:vt100 .
302The port type is
303.Dq Li dialup ,
304the operator is
305.Dq Li \*[Gt] ,
306the baud rate specification is
307.Dq Li 9600 ,
308and the terminal type is
309.Dq Li vt100 .
310The result of this mapping is to specify that if the terminal type is
311.Dq Li dialup ,
312and the baud rate is greater than 9600 baud, a terminal type of
313.Dq Li vt100
314will be used.
315.Pp
316If no port type is specified, the terminal type will match any port type,
317for example,
318.Dq Li -m dialup:vt100 -m :?xterm
319will cause any dialup port, regardless of baud rate, to match the terminal
320type
321.Dq Li vt100 ,
322and any non-dialup port type to match the terminal type
323.Dq Li ?xterm .
324Note, because of the leading question mark, the user will be
325queried on a default port as to whether they are actually using an
326.Ar xterm
327terminal.
328.Pp
329No whitespace characters are permitted in the
330.Fl m
331option argument.
332Also, to avoid problems with metacharacters, it is suggested that the entire
333.Fl m
334option argument be placed within single quote characters, and that
335.Xr csh 1
336users insert a backslash character (``\e'') before any exclamation
337marks (``!'').
338.Sh ENVIRONMENT
339The
340.Nm
341command utilizes the
342.Ev SHELL
343and
344.Ev TERM
345environment variables.
346.Sh FILES
347.Bl -tag -width /usr/share/misc/termcap -compact
348.It Pa /etc/ttys
349system port name to terminal type mapping database
350.It Pa /usr/share/misc/termcap
351terminal capability database
352.El
353.Sh SEE ALSO
354.Xr csh 1 ,
355.Xr sh 1 ,
356.Xr stty 1 ,
357.Xr tty 4 ,
358.Xr termcap 5 ,
359.Xr ttys 5 ,
360.Xr environ 7
361.Sh HISTORY
362The
363.Nm
364command appeared in
365.Bx 3.0 .
366.Sh COMPATIBILITY
367The
368.Fl A ,
369.Fl E ,
370.Fl h ,
371.Fl u
372and
373.Fl v
374options have been deleted from the
375.Nm
376utility.
377None of them were documented in
378.Bx 4.3
379and all are of limited utility at
380best.
381The
382.Fl a ,
383.Fl d
384and
385.Fl p
386options are similarly not documented or useful, but were retained as they
387appear to be in widespread use.
388It is strongly recommended that any usage of these three options be
389changed to use the
390.Fl m
391option instead.
392The
393.Fl n
394option remains, but has no effect.
395It is still permissible to specify the
396.Fl e ,
397.Fl i
398and
399.Fl k
400options without arguments, although it is strongly recommended that such
401usage be fixed to explicitly specify the character.
402.Pp
403Executing
404.Nm
405as
406.Nm reset
407no longer implies the
408.Fl Q
409option.
410Also, the interaction between the
411.Fl
412option and the
413.Ar terminal
414argument in some historic implementations of
415.Nm
416has been removed.
417.Pp
418Finally, the
419.Nm
420implementation has been completely redone (as part of the addition to the
421system of a
422.St -p1003.1-88
423compliant terminal interface) and will no longer compile on systems with
424older terminal interfaces.
425