1.\" $NetBSD: stty.1,v 1.29 2003/08/07 09:05:42 agc Exp $ 2.\" 3.\" Copyright (c) 1990, 1993, 1994 4.\" The Regents of the University of California. All rights reserved. 5.\" 6.\" This code is derived from software contributed to Berkeley by 7.\" the Institute of Electrical and Electronics Engineers, Inc. 8.\" 9.\" Redistribution and use in source and binary forms, with or without 10.\" modification, are permitted provided that the following conditions 11.\" are met: 12.\" 1. Redistributions of source code must retain the above copyright 13.\" notice, this list of conditions and the following disclaimer. 14.\" 2. Redistributions in binary form must reproduce the above copyright 15.\" notice, this list of conditions and the following disclaimer in the 16.\" documentation and/or other materials provided with the distribution. 17.\" 3. Neither the name of the University nor the names of its contributors 18.\" may be used to endorse or promote products derived from this software 19.\" without specific prior written permission. 20.\" 21.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31.\" SUCH DAMAGE. 32.\" 33.\" @(#)stty.1 8.5 (Berkeley) 6/1/94 34.\" 35.Dd June 1, 1994 36.Dt STTY 1 37.Os 38.Sh NAME 39.Nm stty 40.Nd set the options for a terminal device interface 41.Sh SYNOPSIS 42.Nm 43.Op Fl a | Fl e | Fl g 44.Op Fl f Ar file 45.Op operands 46.Sh DESCRIPTION 47The 48.Nm 49utility sets or reports on terminal 50characteristics for the device that is its standard input. 51If no options or operands are specified, it reports the settings of a subset 52of characteristics as well as additional ones if they differ from their 53default values. 54Otherwise it modifies 55the terminal state according to the specified arguments. 56Some combinations of arguments are mutually 57exclusive on some terminal types. 58.Pp 59The following options are available: 60.Bl -tag -width Ds 61.It Fl a 62Display all the current settings for the terminal to standard output 63as per 64.St -p1003.2 . 65.It Fl e 66Display all the current settings for the terminal to standard output 67in the traditional 68.Bx 69``all'' and ``everything'' formats. 70.It Fl f 71Open and use the terminal named by 72.Ar file 73rather than using standard input. 74The file is opened using the 75.Dv O_NONBLOCK 76flag of 77.Fn open , 78making it possible to 79set or display settings on a terminal that might otherwise 80block on the open. 81.It Fl g 82Display all the current settings for the terminal to standard output 83in a form that may be used as an argument to a subsequent invocation of 84.Nm 85to restore the current terminal state as per 86.St -p1003.2 . 87.El 88.Pp 89The following arguments are available to set the terminal 90characteristics: 91.Ss Control Modes 92Control mode flags affect hardware characteristics associated with the 93terminal. 94This corresponds to the c_cflag in the termios structure. 95.Bl -tag -width Fl 96.It Cm parenb Pq Fl parenb 97Enable (disable) parity generation 98and detection. 99.It Cm parodd Pq Fl parodd 100Select odd (even) parity. 101.It Cm cs5 cs6 cs7 cs8 102Select character size, if possible. 103.It Ar number 104Set terminal baud rate to the 105number given, if possible. 106If the 107baud rate is set to zero, modem 108control is no longer 109asserted. 110.It Cm ispeed Ar number 111Set terminal input baud rate to the 112number given, if possible. 113If the 114input baud rate is set to zero, the 115input baud rate is set to the 116value of the output baud 117rate. 118.It Cm ospeed Ar number 119Set terminal output baud rate to 120the number given, if possible. 121If 122the output baud rate is set to 123zero, modem control is 124no longer asserted. 125.It Cm speed Ar number 126This sets both 127.Cm ispeed 128and 129.Cm ospeed 130to 131.Ar number . 132.It Cm hupcl Pq Fl hupcl 133Stop asserting modem control 134(do not stop asserting modem control) on last close. 135.It Cm hup Pq Fl hup 136Same as hupcl 137.Pq Fl hupcl . 138.It Cm cstopb Pq Fl cstopb 139Use two (one) stop bits per character. 140.It Cm cread Pq Fl cread 141Enable (disable) the receiver. 142.It Cm clocal Pq Fl clocal 143Assume a line without (with) modem 144control. 145.It Cm crtscts Pq Fl crtscts 146Enable RTS/CTS flow control. 147.It Cm cdtrcts Pq Fl cdtrcts 148Enable DTR/CTS flow control (if supported). 149.El 150.Ss Input Modes 151This corresponds to the c_iflag in the termios structure. 152.Bl -tag -width Fl 153.It Cm ignbrk Pq Fl ignbrk 154Ignore (do not ignore) break on 155input. 156.It Cm brkint Pq Fl brkint 157Signal (do not signal) 158.Dv INTR 159on 160break. 161.It Cm ignpar Pq Fl ignpar 162Ignore (do not ignore) parity 163errors. 164.It Cm parmrk Pq Fl parmrk 165Mark (do not mark) parity errors. 166.It Cm inpck Pq Fl inpck 167Enable (disable) input parity 168checking. 169.It Cm istrip Pq Fl istrip 170Strip (do not strip) input characters 171to seven bits. 172.It Cm inlcr Pq Fl inlcr 173Map (do not map) 174.Dv NL 175to 176.Dv CR 177on input. 178.It Cm igncr Pq Fl igncr 179Ignore (do not ignore) 180.Dv CR 181on input. 182.It Cm icrnl Pq Fl icrnl 183Map (do not map) 184.Dv CR 185to 186.Dv NL 187on input. 188.It Cm ixon Pq Fl ixon 189Enable (disable) 190.Dv START/STOP 191output 192control. 193Output from the system is 194stopped when the system receives 195.Dv STOP 196and started when the system 197receives 198.Dv START , 199or if 200.Cm ixany 201is set, any character restarts output. 202.It Cm ixoff Pq Fl ixoff 203Request that the system send (not 204send) 205.Dv START/STOP 206characters when 207the input queue is nearly 208empty/full. 209.It Cm ixany Pq Fl ixany 210Allow any character (allow only 211.Dv START ) 212to restart output. 213.It Cm imaxbel Pq Fl imaxbel 214The system imposes a limit of 215.Dv MAX_INPUT 216(currently 255) characters in the input queue. 217If 218.Cm imaxbel 219is set and the input queue limit has been reached, 220subsequent input causes the system to send an ASCII BEL 221character to the output queue (the terminal beeps at you). 222Otherwise, 223if 224.Cm imaxbel 225is unset and the input queue is full, the next input character causes 226the entire input and output queues to be discarded. 227.El 228.Ss Output Modes 229This corresponds to the c_oflag of the termios structure. 230.Bl -tag -width Fl 231.It Cm opost Pq Fl opost 232Post-process output (do not 233post-process output; ignore all other 234output modes). 235.It Cm onlcr Pq Fl onlcr 236Map (do not map) 237.Dv NL 238to 239.Dv CR-NL 240on output. 241.It Cm ocrnl Pq Fl ocrnl 242Map (do not map) 243.Dv CR 244to 245.Dv NL 246on output. 247.It Cm oxtabs Pq Fl oxtabs 248Expand (do not expand) tabs to spaces on output. 249.It Cm onocr Pq Fl onocr 250Do not (do) output CRs at column zero. 251.It Cm onlret Pq Fl onlret 252On the terminal NL performs (does not perform) the CR function. 253.El 254.Ss Local Modes 255Local mode flags (lflags) affect various and sundry characteristics of terminal 256processing. 257Historically the term "local" pertained to new job control features 258implemented by Jim Kulp on a 259.Tn PDP Ns -11/70 260at 261.Tn IIASA . 262Later the driver ran on the first 263.Tn VAX 264at Evans Hall, UC Berkeley, where the job control details 265were greatly modified but the structure definitions and names 266remained essentially unchanged. 267The second interpretation of the 'l' in lflag 268is ``line discipline flag'' which corresponds to the 269.Ar c_lflag 270of the 271.Ar termios 272structure. 273.Bl -tag -width Fl 274.It Cm isig Pq Fl isig 275Enable (disable) the checking of 276characters against the special control 277characters 278.Dv INTR , QUIT , 279and 280.Dv SUSP . 281.It Cm icanon Pq Fl icanon 282Enable (disable) canonical input 283.Pf ( Dv ERASE 284and 285.Dv KILL 286processing). 287.It Cm iexten Pq Fl iexten 288Enable (disable) any implementation 289defined special control characters 290not currently controlled by icanon, 291isig, or ixon. 292.It Cm echo Pq Fl echo 293Echo back (do not echo back) every 294character typed. 295.It Cm echoe Pq Fl echoe 296The 297.Dv ERASE 298character shall (shall 299not) visually erase the last character 300in the current line from the 301display, if possible. 302.It Cm echok Pq Fl echok 303Echo (do not echo) 304.Dv NL 305after 306.Dv KILL 307character. 308.It Cm echoke Pq Fl echoke 309The 310.Dv KILL 311character shall (shall 312not) visually erase 313the current line from the 314display, if possible. 315.It Cm echonl Pq Fl echonl 316Echo (do not echo) 317.Dv NL , 318even if echo 319is disabled. 320.It Cm echoctl Pq Fl echoctl 321If 322.Cm echoctl 323is set, echo control characters as ^X. 324Otherwise control characters echo as themselves. 325.It Cm echoprt Pq Fl echoprt 326For printing terminals. 327If set, echo erased characters backwards within ``\\'' 328and ``/''. 329Otherwise, disable this feature. 330.It Cm noflsh Pq Fl noflsh 331Disable (enable) flush after 332.Dv INTR , QUIT , SUSP . 333.It Cm tostop Pq Fl tostop 334Send (do not send) 335.Dv SIGTTOU 336for background output. 337This causes background jobs to stop if they attempt terminal output. 338.It Cm altwerase Pq Fl altwerase 339Use (do not use) an alternative word erase algorithm when processing 340.Dv WERASE 341characters. 342This alternative algorithm considers sequences of 343alphanumeric/underscores as words. 344It also skips the first preceding character in its classification 345(as a convenience since the one preceding character could have been 346erased with simply an 347.Dv ERASE 348character.) 349.It Cm mdmbuf Pq Fl mdmbuf 350If set, flow control output based on condition of Carrier Detect. 351Otherwise writes return an error if Carrier Detect is low (and Carrier 352is not being ignored with the 353.Dv CLOCAL 354flag.) 355.It Cm flusho Pq Fl flusho 356Indicates output is (is not) being discarded. 357.It Cm pendin Pq Fl pendin 358Indicates input is (is not) pending after a switch from non-canonical 359to canonical mode and will be re-input when a read becomes pending 360or more input arrives. 361.El 362.Ss Control Characters 363.Bl -tag -width Fl 364.It Ar control-character Ar string 365Set 366.Ar control-character 367to 368.Ar string . 369If string is a single character, 370the control character is set to 371that character. 372If string is the 373two character sequence "^-" or the 374string "undef" the control character 375is disabled (i.e. set to 376.Pf { Dv _POSIX_VDISABLE Ns } . ) 377.Pp 378Recognized control-characters: 379.Bd -ragged -offset indent 380.Bl -column character Subscript 381.It control- 382.It character Subscript Description 383.It _________ _________ _______________ 384.It eof Ta Tn VEOF EOF No character 385.It eol Ta Tn VEOL EOL No character 386.It eol2 Ta Tn VEOL2 EOL2 No character 387.It erase Ta Tn VERASE ERASE No character 388.It werase Ta Tn VWERASE WERASE No character 389.It intr Ta Tn VINTR INTR No character 390.It kill Ta Tn VKILL KILL No character 391.It quit Ta Tn VQUIT QUIT No character 392.It susp Ta Tn VSUSP SUSP No character 393.It start Ta Tn VSTART START No character 394.It stop Ta Tn VSTOP STOP No character 395.It dsusp Ta Tn VDSUSP DSUSP No character 396.It lnext Ta Tn VLNEXT LNEXT No character 397.It reprint Ta Tn VREPRINT REPRINT No character 398.It status Ta Tn VSTATUS STATUS No character 399.El 400.Ed 401.It Cm min Ar number 402.It Cm time Ar number 403Set the value of min or time to 404number. 405.Dv MIN 406and 407.Dv TIME 408are used in 409Non-Canonical mode input processing 410(-icanon). 411.El 412.Ss Combination Modes 413.Bl -tag -width Fl 414.It Ar saved settings 415Set the current terminal characteristics to the saved settings 416produced by the 417.Fl g 418option. 419.It Cm evenp No or Cm parity 420Enable parenb and cs7; disable parodd. 421.It Cm oddp 422Enable parenb, cs7, and parodd. 423.It Fl parity , evenp , oddp 424Disable parenb, and set cs8. 425.It Cm \&nl Pq Fl \&nl 426Enable (disable) icrnl. 427In addition 428-nl unsets inlcr and igncr. 429.It Cm ek 430Reset 431.Dv ERASE 432and 433.Dv KILL 434characters back to system defaults. 435.It Cm sane 436Resets all modes to reasonable values for interactive terminal use. 437.It Cm tty 438Set the line discipline to the standard terminal line discipline 439.Dv TTYDISC . 440.It Cm crt Pq Fl crt 441Set (disable) all modes suitable for a CRT display device. 442.It Cm kerninfo Pq Fl kerninfo 443Enable (disable) the system generated status line associated with 444processing a 445.Dv STATUS 446character (usually set to ^T). 447The status line consists of the 448system load average, the current command name, its process ID, the 449event the process is waiting on (or the status of the process), the user 450and system times, percent cpu, and current memory usage. 451.It Cm columns Ar number 452The terminal size is recorded as having 453.Ar number 454columns. 455.It Cm cols Ar number 456is an alias for 457.Cm columns . 458.It Cm rows Ar number 459The terminal size is recorded as having 460.Ar number 461rows. 462.It Cm dec 463Set modes suitable for users of Digital Equipment Corporation systems ( 464.Dv ERASE , 465.Dv KILL , 466and 467.Dv INTR 468characters are set to ^?, ^U, and ^C; 469.Dv ixany 470is disabled, and 471.Dv crt 472is enabled.) 473.It Cm extproc Pq Fl extproc 474If set, this flag indicates that some amount of terminal processing is being 475performed by either the terminal hardware or by the remote side connected 476to a pty. 477.It Cm raw Pq Fl raw 478If set, change the modes of the terminal so that no input or output processing 479is performed. 480If unset, change the modes of the terminal to some reasonable 481state that performs input and output processing. 482Note that since the terminal driver no longer has a single 483.Dv RAW 484bit, it is not possible to intuit what flags were set prior to setting 485.Cm raw . 486This means that unsetting 487.Cm raw 488may not put back all the setting that were previously in effect. 489To set the terminal into a raw state and then accurately restore it, the following 490shell code is recommended: 491.Bd -literal -offset indent 492save_state=$(stty -g) 493stty raw 494\&... 495stty "$save_state" 496.Ed 497.It Cm size 498The size of the terminal is printed as two numbers on a single line, 499first rows, then columns. 500.El 501.Ss Compatibility Modes 502These modes remain for compatibility with the previous version of 503the stty command. 504.Bl -tag -width Fl 505.It Cm all 506Reports all the terminal modes as with 507.Cm stty Fl a 508except that the control characters are printed in a columnar format. 509.It Cm everything 510Same as 511.Cm all . 512.It Cm cooked 513Same as 514.Cm sane . 515.It Cm cbreak 516If set, enables 517.Cm brkint , ixon , imaxbel , opost , 518.Cm isig , iexten , 519and 520.Fl icanon . 521If unset, same as 522.Cm sane . 523.It Cm new 524Same as 525.Cm tty . 526.It Cm old 527Same as 528.Cm tty . 529.It Cm newcrt Pq Fl newcrt 530Same as 531.Cm crt . 532.It Cm pass8 533The converse of 534.Cm parity . 535.It Cm tandem Pq Fl tandem 536Same as 537.Cm ixoff . 538.It Cm decctlq Pq Fl decctlq 539The converse of 540.Cm ixany . 541.It Cm crterase Pq Fl crterase 542Same as 543.Cm echoe . 544.It Cm crtbs Pq Fl crtbs 545Same as 546.Cm echoe . 547.It Cm crtkill Pq Fl crtkill 548Same as 549.Cm echoke . 550.It Cm ctlecho Pq Fl ctlecho 551Same as 552.Cm echoctl . 553.It Cm prterase Pq Fl prterase 554Same as 555.Cm echoprt . 556.It Cm litout Pq Fl litout 557The converse of 558.Cm opost . 559.It Cm tabs Pq Fl tabs 560The converse of 561.Cm oxtabs . 562.It Cm brk Ar value 563Same as the control character 564.Cm eol . 565.It Cm flush Ar value 566Same as the control character 567.Cm discard . 568.It Cm rprnt Ar value 569Same as the control character 570.Cm reprint . 571.El 572.Ss Control operations 573These operations are not modes, but rather commands to be performed by 574the tty layer. 575.Bl -tag -width Fl 576.It Cm ostart 577Performs a "start output" operation, as normally done by an 578incoming START character when 579.Cm ixon 580is set. 581.It Cm ostop 582Performs a "stop output" operation, as normally done by an 583incoming STOP character when 584.Cm ixon 585is set. 586.El 587.Sh EXIT STATUS 588The 589.Nm 590utility exits with a value of 0 if successful, and \*[Gt]0 if an error occurs. 591.Sh SEE ALSO 592.Xr termios 4 593.Sh STANDARDS 594The 595.Nm 596utility is expected to be 597.St -p1003.2 598compatible. 599The flags 600.Fl e 601and 602.Fl f 603are 604extensions to the standard, as are the operands mentioned in the control 605operations section. 606