Debian Codegraph @

upstream/debian-unstable/man1/tset.1

raw
1 .\"***************************************************************************
2 .\" Copyright 2018-2024,2025 Thomas E. Dickey *
3 .\" Copyright 1998-2016,2017 Free Software Foundation, Inc. *
4 .\" *
5 .\" Permission is hereby granted, free of charge, to any person obtaining a *
6 .\" copy of this software and associated documentation files (the *
7 .\" "Software"), to deal in the Software without restriction, including *
8 .\" without limitation the rights to use, copy, modify, merge, publish, *
9 .\" distribute, distribute with modifications, sublicense, and/or sell *
10 .\" copies of the Software, and to permit persons to whom the Software is *
11 .\" furnished to do so, subject to the following conditions: *
12 .\" *
13 .\" The above copyright notice and this permission notice shall be included *
14 .\" in all copies or substantial portions of the Software. *
15 .\" *
16 .\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
17 .\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
18 .\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
19 .\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
20 .\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
21 .\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
22 .\" THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
23 .\" *
24 .\" Except as contained in this notice, the name(s) of the above copyright *
25 .\" holders shall not be used in advertising or otherwise to promote the *
26 .\" sale, use or other dealings in this Software without prior written *
27 .\" authorization. *
28 .\"***************************************************************************
29 .\"
30 .\" $Id: tset.1,v 1.94 2025/01/19 00:51:54 tom Exp $
31 .TH tset 1 2025-01-18 "ncurses 6.6" "User commands"
32 .ie \n(.g \{\
33 .ds `` \(lq
34 .ds '' \(rq
35 .ds ^ \(ha
36 .\}
37 .el \{\
38 .ie t .ds `` ``
39 .el .ds `` ""
40 .ie t .ds '' ''
41 .el .ds '' ""
42 .ds ^ ^
43 .\}
44 .
45 .de bP
46 .ie n .IP \(bu 4
47 .el .IP \(bu 2
48 ..
49 .
50 .SH NAME
51 \fB\%tset\fP,
52 \fB\%reset\fP \-
53 initialize or reset terminal state
54 .SH SYNOPSIS
55 \fBtset\fP [\fB\-IQVcqrsw\fP] [\fB\-\fP] [\fB\-e\fP \fIch\fP] [\fB\-i\fP \fIch\fP] [\fB\-k\fP \fIch\fP] [\fB\-m\fP \fImapping\fP] [\fIterminal-type\fP]
56 .br
57 \fBreset\fP [\fB\-IQVcqrsw\fP] [\fB\-\fP] [\fB\-e\fP \fIch\fP] [\fB\-i\fP \fIch\fP] [\fB\-k\fP \fIch\fP] [\fB\-m\fP \fImapping\fP] [\fIterminal-type\fP]
58 .SH DESCRIPTION
59 .SS "\fItset\fP \(em initialization"
60 This program initializes terminals.
61 .PP
62 First, \fBtset\fP retrieves the current terminal mode settings
63 for your terminal.
64 It does this by successively testing
65 .bP
66 the standard error,
67 .bP
68 standard output,
69 .bP
70 standard input and
71 .bP
72 ultimately \*(``/dev/tty\*(''
73 .PP
74 to obtain terminal settings.
75 Having retrieved these settings, \fBtset\fP remembers which
76 file descriptor to use when updating settings.
77 .PP
78 Next, \fBtset\fP determines the type of terminal that you are using.
79 This determination is done as follows, using the first terminal type found.
80 .PP
81 1. The \fBterminal\fP argument specified on the command line.
82 .PP
83 2. The value of the \fITERM\fP environment variable.
84 .PP
85 3. (BSD systems only.) The terminal type associated with the standard
86 error output device in the \fI/etc/ttys\fP file.
87 (On System\ V hosts and systems using that convention,
88 \fI\%getty\fP(8) does this job by setting
89 \fITERM\fP according to the type passed to it by \fI\%/etc/inittab\fP.)
90 .PP
91 4. The default terminal type, \*(``unknown\*('',
92 is not suitable for curses applications.
93 .PP
94 If the terminal type was not specified on the command-line, the \fB\-m\fP
95 option mappings are then applied;
96 see subsection \*(``Terminal Type Mapping\*(''.
97 Then, if the terminal type begins with a question mark (\*(``?\*(''), the
98 user is prompted for confirmation of the terminal type.
99 An empty
100 response confirms the type, or, another type can be entered to specify
101 a new type.
102 Once the terminal type has been determined,
103 the terminal description for the terminal is retrieved.
104 If no terminal description is found
105 for the type, the user is prompted for another terminal type.
106 .PP
107 Once the terminal description is retrieved,
108 .bP
109 if the \*(``\fB\-w\fP\*('' option is enabled, \fBtset\fP may update
110 the terminal's window size.
111 .IP
112 If the window size cannot be obtained from the operating system,
113 but the terminal description
114 (or environment,
115 e.g.,
116 \fILINES\fP and \fI\%COLUMNS\fP variables specify this),
117 use this to set the operating system's notion of the window size.
118 .bP
119 if the \*(``\fB\-c\fP\*('' option is enabled,
120 the backspace, interrupt and line kill characters
121 (among many other things) are set
122 .bP
123 unless the \*(``\fB\-I\fP\*('' option is enabled,
124 the terminal
125 and tab \fIinitialization\fP strings are sent to the standard error output,
126 and,
127 if the terminal device does not appear to be a pseudoterminal
128 (as might be used by a terminal emulator program),
129 \fBtset\fP waits one second in case a hardware reset was issued.
130 .bP
131 Finally, if the erase, interrupt and line kill characters have changed,
132 or are not set to their default values, their values are displayed to the
133 standard error output.
134 .SS "\fIreset\fP \(em reinitialization"
135 When invoked as \fBreset\fP, \fBtset\fP sets the terminal
136 modes to \*(``sane\*('' values:
137 .bP
138 sets canonical (\*(``cooked\*('') and echo modes,
139 .bP
140 turns off cbreak and raw modes,
141 .bP
142 turns on newline translation and
143 .bP
144 resets special input characters to their default values
145 .PP
146 before
147 doing the terminal initialization described above.
148 Also, rather than using the terminal \fIinitialization\fP strings,
149 it uses the terminal \fIreset\fP strings.
150 .PP
151 The \fBreset\fP command is useful
152 after a program dies leaving a terminal in an abnormal state:
153 .bP
154 you may have to type
155 .sp
156 \fI<LF>\fBreset\fI<LF>\fR
157 .sp
158 (the line-feed character is normally control-J) to get the terminal
159 to work, as carriage-return may no longer work in the abnormal state.
160 .bP
161 Also, the terminal will often not echo the command.
162 .SS "Setting the Environment"
163 It is often desirable to enter the terminal type and information about
164 the terminal's capabilities into the shell's environment.
165 This is done using the \fB\-s\fP option.
166 .PP
167 When the \fB\-s\fP option is specified, the commands to enter the information
168 into the shell's environment are written to the standard output.
169 If the \fISHELL\fP environment variable ends in \*(``csh\*('',
170 the commands
171 are for \fIcsh\fP(1),
172 otherwise,
173 they are for \fIsh\fP(1).
174 The \fIcsh\fP commands set and unset the shell variable \fBnoglob\fP,
175 leaving it unset.
176 The following line in the \fB.login\fP
177 or \fB.profile\fP files will initialize the environment correctly:
178 .sp
179 eval \(gatset \-s options ... \(ga
180 .
181 .SS "Terminal Type Mapping"
182 When the terminal is not hardwired into the system (or the current
183 system information is incorrect) the terminal type derived from the
184 \fI/etc/ttys\fP file or the \fITERM\fP environment variable is often
185 something generic like \fBnetwork\fP, \fBdialup\fP, or \fBunknown\fP.
186 When \fBtset\fP is used in a startup script it is often desirable to
187 provide information about the type of terminal used on such ports.
188 .PP
189 The \fB\-m\fP options maps
190 from some set of conditions to a terminal type, that is, to
191 tell \fBtset\fP
192 \*(``If I'm on this port at a particular speed,
193 guess that I'm on that kind of terminal\*(''.
194 .PP
195 The argument to the \fB\-m\fP option consists of an optional port type, an
196 optional operator, an optional baud rate specification, an optional
197 colon (\*(``:\*('') character and a terminal type.
198 The port type is a
199 string (delimited by either the operator or the colon character).
200 The operator may be any combination of
201 \*(``>\*('',
202 \*(``<\*('',
203 \*(``@\*('',
204 and \*(``!\*('';
205 \*(``>\*('' means greater than,
206 \*(``<\*('' means less than,
207 \*(``@\*('' means equal to and
208 \*(``!\*('' inverts the sense of the test.
209 The baud rate is specified as a number and is compared with the speed
210 of the standard error output (which should be the control terminal).
211 The terminal type is a string.
212 .PP
213 If the terminal type is not specified on the command line, the \fB\-m\fP
214 mappings are applied to the terminal type.
215 If the port type and baud
216 rate match the mapping, the terminal type specified in the mapping
217 replaces the current type.
218 If more than one mapping is specified, the
219 first applicable mapping is used.
220 .PP
221 For example, consider the following mapping: \fBdialup>9600:vt100\fP.
222 The port type is dialup , the operator is >, the baud rate
223 specification is 9600, and the terminal type is vt100.
224 The result of
225 this mapping is to specify that if the terminal type is \fBdialup\fP,
226 and the baud rate is greater than 9600 baud, a terminal type of
227 \fBvt100\fP will be used.
228 .PP
229 If no baud rate is specified, the terminal type will match any baud rate.
230 If no port type is specified, the terminal type will match any port type.
231 For example, \fB\-m dialup:vt100 \-m :?xterm\fP
232 will cause any dialup port, regardless of baud rate, to match the terminal
233 type vt100, and any non-dialup port type to match the terminal type ?xterm.
234 Note, because of the leading question mark, the user will be
235 queried on a default port as to whether they are actually using an xterm
236 terminal.
237 .PP
238 No whitespace characters are permitted in the \fB\-m\fP option argument.
239 Also, to avoid problems with meta-characters, it is suggested that the
240 entire \fB\-m\fP option argument be placed within single quote characters,
241 and that \fIcsh\fP users insert a backslash character (\*(``\e\*('')
242 before any exclamation marks (\*(``!\*('').
243 .SH OPTIONS
244 The options are as follows:
245 .TP 5
246 .B \-c
247 Set control characters and modes.
248 .TP 5
249 .BI \-e\ ch
250 Set the erase character to \fIch\fP.
251 .TP
252 .B \-I
253 Do not send the terminal or tab initialization strings to the terminal.
254 .TP
255 .BI \-i\ ch
256 Set the interrupt character to \fIch\fP.
257 .TP
258 .BI \-k\ ch
259 Set the line kill character to \fIch\fP.
260 .TP
261 .BI \-m\ mapping
262 Specify a mapping from a port type to a terminal;
263 see subsection \*(``Terminal Type Mapping\*(''.
264 .TP
265 .B \-Q
266 Do not display any values for the erase, interrupt and line kill characters.
267 Normally \fBtset\fP displays the values for control characters which
268 differ from the system's default values.
269 .TP
270 .B \-q
271 The terminal type is displayed to the standard output, and the terminal is
272 not initialized in any way.
273 The option \*(``\-\*('' by itself is equivalent but archaic.
274 .TP
275 .B \-r
276 Print the terminal type to the standard error output.
277 .TP
278 .B \-s
279 Print the sequence of shell commands to initialize the environment variable
280 \fITERM\fP to the standard output;
281 see subsection \*(``Setting the Environment\*(''.
282 .TP
283 .B \-V
284 reports the version of \fI\%ncurses\fP which was used in this program,
285 and exits.
286 .TP
287 .B \-w
288 Resize the window to match the size deduced via \fBsetupterm\fP(3NCURSES).
289 Normally this has no effect,
290 unless \fBsetupterm\fP is not able to detect the window size.
291 .PP
292 The arguments for the \fB\-e\fP, \fB\-i\fP, and \fB\-k\fP
293 options may either be entered as actual characters
294 or by using the \*(``hat\*(''
295 notation, i.e., control-h may be specified as \*(``\*^H\*('' or \*(``\*^h\*(''.
296 .PP
297 If neither \fB\-c\fP or \fB\-w\fP is given, both options are assumed.
298 .SH ENVIRONMENT
299 The \fBtset\fP command uses these environment variables:
300 .TP 5
301 .I SHELL
302 tells \fBtset\fP whether to initialize \fITERM\fP using \fIsh\fP(1) or
303 \fIcsh\fP(1) syntax.
304 .TP 5
305 .I TERM
306 Denotes your terminal type.
307 Each terminal type is distinct, though many are similar.
308 .TP 5
309 .I TERMCAP
310 may denote the location of a termcap database.
311 If it is not an absolute pathname, e.g., begins with a \*(``/\*('',
312 \fBtset\fP removes the variable from the environment before looking
313 for the terminal description.
314 .SH FILES
315 .TP
316 .I /etc/ttys
317 system port name to terminal type mapping database (BSD versions only).
318 .TP
319 .I /etc/terminfo
320 compiled terminal description database directory
321 .SH PORTABILITY
322 Neither IEEE Std 1003.1/The Open Group Base Specifications Issue\ 7
323 (POSIX.1-2008) nor
324 X/Open Curses Issue\ 7 documents \fBtset\fP or \fBreset\fP.
325 .PP
326 The AT&T \fBtput\fP utility (AIX, HP-UX, Solaris)
327 incorporated the terminal-mode manipulation as well as termcap-based features
328 such as resetting tabstops from \fBtset\fP in BSD (4.1c),
329 presumably with the intention of making \fBtset\fP obsolete.
330 However, each of those systems still provides \fBtset\fP.
331 In fact, the commonly-used \fBreset\fP utility
332 is always an alias for \fBtset\fP.
333 .PP
334 The \fB\%tset\fP utility provides backward compatibility with BSD
335 environments;
336 under most modern Unices,
337 \fI\%/etc/inittab\fP and \fI\%getty\fP(8) can set \fITERM\fP
338 appropriately for each dial-up line,
339 obviating what was \fB\%tset\fP's most important use.
340 This implementation behaves like 4.4BSD \fBtset\fP,
341 with a few exceptions we shall consider now.
342 .PP
343 A few options are different
344 because the \fI\%TERMCAP\fP variable
345 is no longer supported under terminfo-based \fI\%ncurses\fP:
346 .bP
347 The \fB\-S\fP option of BSD \fBtset\fP no longer works;
348 it prints an error message to the standard error and dies.
349 .bP
350 The \fB\-s\fP option only sets \fITERM\fP,
351 not \fI\%TERMCAP\fP.
352 .PP
353 There was an undocumented 4.4BSD feature
354 that invoking \fBtset\fP via a link named
355 \*(``TSET\*('' (or via any other name beginning with an upper-case letter)
356 set the terminal to use upper-case only.
357 This feature has been omitted.
358 .PP
359 The \fB\-A\fP, \fB\-E\fP, \fB\-h\fP, \fB\-u\fP and \fB\-v\fP
360 options were deleted from the \fBtset\fP
361 utility in 4.4BSD.
362 None of them were documented in 4.3BSD and all are
363 of limited utility at best.
364 The \fB\-a\fP, \fB\-d\fP, and \fB\-p\fP options are similarly
365 not documented or useful, but were retained as they appear to be in
366 widespread use.
367 It is strongly recommended that any usage of these
368 three options be changed to use the \fB\-m\fP option instead.
369 The \fB\-a\fP, \fB\-d\fP, and \fB\-p\fP options
370 are therefore omitted from the usage summary above.
371 .PP
372 Very old systems, e.g., 3BSD, used a different terminal driver which
373 was replaced in 4BSD in the early 1980s.
374 To accommodate these older systems, the 4BSD \fBtset\fP provided a
375 \fB\-n\fP option to specify that the new terminal driver should be used.
376 This implementation does not provide that choice.
377 .PP
378 It is still permissible to specify the \fB\-e\fP, \fB\-i\fP,
379 and \fB\-k\fP options without arguments,
380 although it is strongly recommended that such usage be fixed to
381 explicitly specify the character.
382 .PP
383 As of 4.4BSD,
384 executing \fBtset\fP as \fBreset\fP no longer implies the \fB\-Q\fP option.
385 Also, the interaction between the \- option and the \fIterminal\fP
386 argument in some historic implementations of \fBtset\fP has been removed.
387 .PP
388 The \fB\-c\fP and \fB\-w\fP options are not found in earlier implementations.
389 However, a different window size-change feature was provided in 4.4BSD.
390 .bP
391 In 4.4BSD, \fBtset\fP uses the window size from the termcap description
392 to set the window size if \fBtset\fP is not able to obtain the window
393 size from the operating system.
394 .bP
395 In \fI\%ncurses\fP, \fBtset\fP obtains the window size using
396 \fB\%setupterm\fP(3NCURSES), which may be from
397 the operating system,
398 the \fILINES\fP and \fICOLUMNS\fP environment variables or
399 the terminal description.
400 .PP
401 Obtaining the window size from a terminal's type description is common
402 to both implementations,
403 but considered obsolescent.
404 Its only practical use is for hardware terminals.
405 Generally,
406 the window size will remain uninitialized only if there were a problem
407 obtaining the value from the operating system
408 (and \fB\%setupterm\fP would still fail).
409 The \fILINES\fP and \fI\%COLUMNS\fP environment variables
410 may thus be useful for working around window-size problems,
411 but have the drawback that if the window is resized,
412 their values must be recomputed and reassigned.
413 The \fI\%resize\fP(1) program distributed with
414 \fI\%xterm\fP(1) assists this activity.
415 .SH HISTORY
416 A \fB\%reset\fP command written by Kurt Shoens appeared in 1BSD
417 (March 1978).
418 .\" https://minnie.tuhs.org/cgi-bin/utree.pl?file=1BSD/s6/reset.c
419 It set the \fIerase\fP and \fIkill\fP characters
420 to \fB\*^H\fP (backspace) and \fB@\fP respectively.
421 Mark Horton improved this \fB\%reset\fP in 3BSD
422 (October 1979),
423 adding \fIintr\fP,
424 \fIquit\fP,
425 \fIstart\fP/\fIstop\fP,
426 and \fIeof\fP
427 characters as well as changing the program to avoid modifying any user
428 settings.
429 .\" https://minnie.tuhs.org/cgi-bin/utree.pl?file=3BSD/usr/src/cmd/\
430 .\" reset.c
431 That version of \fB\%reset\fP did not use \fI\%termcap\fP.
432 .PP
433 Eric Allman wrote a distinct \fBtset\fP command for 1BSD,
434 using a forerunner of \fI\%termcap\fP called \fI\%ttycap\fP.
435 .\" https://minnie.tuhs.org/cgi-bin/utree.pl?file=1BSD/s6/tset.c
436 .\" https://minnie.tuhs.org/cgi-bin/utree.pl?file=1BSD/man7/ttycap.7
437 Allman's comments in the source code indicate
438 that he began work in October 1977,
439 continuing development over the next few years.
440 By late 1979,
441 it had migrated to \fI\%termcap\fP and handled the \fI\%TERMCAP\fP
442 variable.
443 .\" https://minnie.tuhs.org/cgi-bin/utree.pl?file=3BSD/usr/src/cmd/\
444 .\" tset/tset.c
445 Later comments indicate that \fBtset\fP was modified in September 1980
446 to use logic copied from the 3BSD \*(``reset\*('' program when it was
447 invoked as \fB\%reset\fP.
448 .\" https://minnie.tuhs.org/cgi-bin/utree.pl?file=2.9BSD/usr/src/ucb/\
449 .\" tset/tset.c
450 This version appeared in 4.1cBSD, \" and backported to 2.9BSD
451 late in 1982.
452 Other developers such as Keith Bostic and Jim Bloom continued to modify
453 \fBtset\fP until 4.4BSD was released in 1993.
454 .PP
455 The \fI\%ncurses\fP implementation was lightly adapted from the 4.4BSD
456 sources to use the \fI\%terminfo\fP API by Eric S.\& Raymond
457 <[email protected]>.
458 .SH SEE ALSO
459 \fB\%csh\fP(1),
460 \fB\%sh\fP(1),
461 \fB\%stty\fP(1),
462 \fB\%terminfo\fP(3NCURSES),
463 \fB\%tty\fP(4),
464 \fB\%terminfo\fP(5),
465 \fB\%ttys\fP(4),
466 \fB\%environ\fP(7)