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