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