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