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