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