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