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