The Regents of the University of California. All rights reserved.
This code is derived from software contributed to Berkeley by
the Institute of Electrical and Electronics Engineers, Inc.
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. All advertising materials mentioning features or use of this software
must display the following acknowledgement:
This product includes software developed by the University of
California, Berkeley and its contributors.
4. 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.
@(#)stty.1 8.4 (Berkeley) 4/18/94
$FreeBSD: head/bin/stty/stty.1 21673 1997-01-14 07:20:47Z jkh $
.Dd April 18, 1994 .Dt STTY 1 .Os .Sh NAME .Nm stty .Nd set the options for a terminal device interface .Sh SYNOPSIS .Nm stty .Op Fl a | Fl e | Fl g .Op Fl f Ar file .Op operands .Sh DESCRIPTION The .Nm stty utility sets or reports on terminal characteristics for the device that is its standard input. If no options or operands are specified, it reports the settings of a subset of characteristics as well as additional ones if they differ from their default values. Otherwise it modifies the terminal state according to the specified arguments. Some combinations of arguments are mutually exclusive on some terminal types.
p The following options are available: l -tag -width Ds t Fl a Display all the current settings for the terminal to standard output as per .St -p1003.2 . t Fl e Display all the current settings for the terminal to standard output in the traditional .Tn BSD ``all'' and ``everything'' formats. t Fl f Open and use the terminal named by .Ar file rather than using standard input. The file is opened using the .Dv O_NONBLOCK flag of .Fn open , making it possible to set or display settings on a terminal that might otherwise block on the open. t Fl g Display all the current settings for the terminal to standard output in a form that may be used as an argument to a subsequent invocation of .Nm stty to restore the current terminal state as per .St -p1003.2 . .El
p The following arguments are available to set the terminal characteristics: .Ss Control Modes:
p Control mode flags affect hardware characteristics associated with the terminal. This corresponds to the c_cflag in the termios structure. l -tag -width Fl t Cm parenb Pq Fl parenb Enable (disable) parity generation and detection. t Cm parodd Pq Fl parodd Select odd (even) parity. t Cm cs5 cs6 cs7 cs8 Select character size, if possible. t Ar number Set terminal baud rate to the number given, if possible. If the baud rate is set to zero, modem control is no longer asserted. t Cm ispeed Ar number Set terminal input baud rate to the number given, if possible. If the input baud rate is set to zero, the input baud rate is set to the value of the output baud rate. t Cm ospeed Ar number Set terminal output baud rate to the number given, if possible. If the output baud rate is set to zero, modem control is no longer asserted. t Cm speed Ar number This sets both .Cm ispeed and .Cm ospeed to .Ar number . t Cm hupcl Pq Fl hupcl Stop asserting modem control (do not stop asserting modem control) on last close. t Cm hup Pq Fl hup Same as hupcl
q Fl hupcl . t Cm cstopb Pq Fl cstopb Use two (one) stop bits per character. t Cm cread Pq Fl cread Enable (disable) the receiver. t Cm clocal Pq Fl clocal Assume a line without (with) modem control. t Cm crtscts Pq Fl crtscts Enable RTS/CTS flow control. .El .Ss Input Modes: This corresponds to the c_iflag in the termios structure. l -tag -width Fl t Cm ignbrk Pq Fl ignbrk Ignore (do not ignore) break on input. t Cm brkint Pq Fl brkint Signal (do not signal) .Dv INTR on break. t Cm ignpar Pq Fl ignpar Ignore (do not ignore) characters with parity errors. t Cm parmrk Pq Fl parmrk Mark (do not mark) characters with parity errors. t Cm inpck Pq Fl inpck Enable (disable) input parity checking. t Cm istrip Pq Fl istrip Strip (do not strip) input characters to seven bits. t Cm inlcr Pq Fl inlcr Map (do not map) .Dv NL to .Dv CR on input. t Cm igncr Pq Fl igncr Ignore (do not ignore) .Dv CR on input. t Cm icrnl Pq Fl icrnl Map (do not map) .Dv CR to .Dv NL on input. t Cm ixon Pq Fl ixon Enable (disable) .Dv START/STOP output control. Output from the system is stopped when the system receives .Dv STOP and started when the system receives .Dv START , or if .Cm ixany is set, any character restarts output. t Cm ixoff Pq Fl ixoff Request that the system send (not send) .Dv START/STOP characters when the input queue is nearly empty/full. t Cm ixany Pq Fl ixany Allow any character (allow only .Dv START ) to restart output. t Cm imaxbel Pq Fl imaxbel The system imposes a limit of .Dv MAX_INPUT (currently 255) characters in the input queue. If .Cm imaxbel is set and the input queue limit has been reached, subsequent input causes the system to send an ASCII BEL character to the output queue (the terminal beeps at you). Otherwise, if .Cm imaxbel is unset and the input queue is full, the next input character causes the entire input and output queues to be discarded. .El .Ss Output Modes: This corresponds to the c_oflag of the termios structure. l -tag -width Fl t Cm opost Pq Fl opost Post-process output (do not post-process output; ignore all other output modes). t Cm onlcr Pq Fl onlcr Map (do not map) .Dv NL to .Dv CR-NL on output. t Cm oxtabs Pq Fl oxtabs Expand (do not expand) tabs to spaces on output. .El .Ss Local Modes:
p Local mode flags (lflags) affect various and sundry characteristics of terminal processing. Historically the term "local" pertained to new job control features implemented by Jim Kulp on a .Tn Pdp 11/70 at .Tn IIASA . Later the driver ran on the first .Tn VAX at Evans Hall, UC Berkeley, where the job control details were greatly modified but the structure definitions and names remained essentially unchanged. The second interpretation of the 'l' in lflag is ``line discipline flag'' which corresponds to the .Ar c_lflag of the .Ar termios structure. l -tag -width Fl t Cm isig Pq Fl isig Enable (disable) the checking of characters against the special control characters .Dv INTR , QUIT , and .Dv SUSP . t Cm icanon Pq Fl icanon Enable (disable) canonical input
f ( Dv ERASE and .Dv KILL processing). t Cm iexten Pq Fl iexten Enable (disable) any implementation defined special control characters not currently controlled by icanon, isig, or ixon. t Cm echo Pq Fl echo Echo back (do not echo back) every character typed. t Cm echoe Pq Fl echoe The .Dv ERASE character shall (shall not) visually erase the last character in the current line from the display, if possible. t Cm echok Pq Fl echok Echo (do not echo) .Dv NL after .Dv KILL character. t Cm echoke Pq Fl echoke The .Dv KILL character shall (shall not) visually erase the the current line from the display, if possible. t Cm echonl Pq Fl echonl Echo (do not echo) .Dv NL , even if echo is disabled. t Cm echoctl Pq Fl echoctl If .Cm echoctl is set, echo control characters as ^X. Otherwise control characters echo as themselves. t Cm echoprt Pq Fl echoprt For printing terminals. If set, echo erased characters backwards within ``\\'' and ``/''. Otherwise, disable this feature. t Cm noflsh Pq Fl noflsh Disable (enable) flush after .Dv INTR , QUIT , SUSP . t Cm tostop Pq Fl tostop Send (do not send) .Dv SIGTTOU for background output. This causes background jobs to stop if they attempt terminal output. t Cm altwerase Pq Fl altwerase Use (do not use) an alternate word erase algorithm when processing .Dv WERASE characters. This alternate algorithm considers sequences of alphanumeric/underscores as words. It also skips the first preceding character in its classification (as a convenience since the one preceding character could have been erased with simply an .Dv ERASE character.) t Cm mdmbuf Pq Fl mdmbuf If set, flow control output based on condition of Carrier Detect. Otherwise writes return an error if Carrier Detect is low (and Carrier is not being ignored with the .Dv CLOCAL flag.) t Cm flusho Pq Fl flusho Indicates output is (is not) being discarded. t Cm pendin Pq Fl pendin Indicates input is (is not) pending after a switch from non-canonical to canonical mode and will be re-input when a read becomes pending or more input arrives. .El .Ss Control Characters: l -tag -width Fl t Ar control-character Ar string Set .Ar control-character to .Ar string . If string is a single character, the control character is set to that character. If string is the two character sequence "^-" or the string "undef" the control character is disabled (i.e. set to
f { Dv _POSIX_VDISABLE Ns } . )
p Recognized control-characters: d -ragged -offset indent l -column character Subscript t control- t character Subscript Description t _________ _________ _______________ t eof Ta Tn VEOF EOF No character t eol Ta Tn VEOL EOL No character t eol2 Ta Tn VEOL2 EOL2 No character t erase Ta Tn VERASE ERASE No character t werase Ta Tn VWERASE WERASE No character t intr Ta Tn VINTR INTR No character t kill Ta Tn VKILL KILL No character t quit Ta Tn VQUIT QUIT No character t susp Ta Tn VSUSP SUSP No character t start Ta Tn VSTART START No character t stop Ta Tn VSTOP STOP No character t dsusp Ta Tn VDSUSP DSUSP No character t lnext Ta Tn VLNEXT LNEXT No character t reprint Ta Tn VREPRINT REPRINT No character t status Ta Tn VSTATUS STATUS No character .El .Ed t Cm min Ar number t Cm time Ar number Set the value of min or time to number. .Dv MIN and .Dv TIME are used in Non-Canonical mode input processing (-icanon). .El .Ss Combination Modes:
p l -tag -width Fl t Ar saved settings Set the current terminal characteristics to the saved settings produced by the .Fl g option. t Cm evenp No or Cm parity Enable parenb and cs7; disable parodd. t Cm oddp Enable parenb, cs7, and parodd. t Fl parity , evenp , oddp Disable parenb, and set cs8. t Cm nl Pq Fl nl Enable (disable) icrnl. In addition -nl unsets inlcr and igncr. t Cm ek Reset .Dv ERASE and .Dv KILL characters back to system defaults. t Cm sane Resets all modes to reasonable values for interactive terminal use. t Cm tty Set the line discipline to the standard terminal line discipline .Dv TTYDISC . t Cm crt Pq Fl crt Set (disable) all modes suitable for a CRT display device. t Cm kerninfo Pq Fl kerninfo Enable (disable) the system generated status line associated with processing a .Dv STATUS character (usually set to ^T). The status line consists of the system load average, the current command name, its process ID, the event the process is waiting on (or the status of the process), the user and system times, percent cpu, and current memory usage. t Cm columns Ar number The terminal size is recorded as having .Ar number columns. t Cm cols Ar number is an alias for .Cm columns. t Cm rows Ar number The terminal size is recorded as having .Ar number rows. t Cm dec Set modes suitable for users of Digital Equipment Corporation systems ( .Dv ERASE , .Dv KILL , and .Dv INTR characters are set to ^?, ^U, and ^C; .Dv ixany is disabled, and .Dv crt is enabled.) t Cm extproc Pq Fl extproc If set, this flag indicates that some amount of terminal processing is being performed by either the terminal hardware or by the remote side connected to a pty. t Cm raw Pq Fl raw If set, change the modes of the terminal so that no input or output processing is performed. If unset, change the modes of the terminal to some reasonable state that performs input and output processing. Note that since the terminal driver no longer has a single .Dv RAW bit, it is not possible to intuit what flags were set prior to setting .Cm raw . This means that unsetting .Cm raw may not put back all the setting that were previously in effect. To set the terminal into a raw state and then accurately restore it, the following shell code is recommended:
save_state=$(stty -g) stty raw ... stty "$save_state"t Cm size The size of the terminal is printed as two numbers on a single line, first rows, then columns. .El .Ss Compatibility Modes:
p These modes remain for compatibility with the previous version of the stty command. l -tag -width Fl t Cm all Reports all the terminal modes as with .Cm stty Fl a except that the control characters are printed in a columnar format. t Cm everything Same as .Cm all . t Cm cooked Same as .Cm sane . t Cm cbreak If set, enables .Cm brkint , ixon , imaxbel , opost , .Cm isig , iexten , and .Cm Fl icanon . If unset, same as .Cm sane . t Cm new Same as .Cm tty . t Cm old Same as .Cm tty . t Cm newcrt Pq Fl newcrt Same as .Cm crt . t Cm pass8 The converse of .Cm parity . t Cm tandem Pq Fl tandem Same as .Cm ixoff . t Cm decctlq Pq Fl decctlq The converse of .Cm ixany . t Cm crterase Pq Fl crterase Same as .Cm echoe . t Cm crtbs Pq Fl crtbs Same as .Cm echoe . t Cm crtkill Pq Fl crtkill Same as .Cm echoke . t Cm ctlecho Pq Fl ctlecho Same as .Cm echoctl . t Cm prterase Pq Fl prterase Same as .Cm echoprt . t Cm litout Pq Fl litout The converse of .Cm opost . t Cm tabs Pq Fl tabs The converse of .Cm tabs . t Cm brk Ar value Same as the control character .Cm eol . t Cm flush Ar value Same as the control character .Cm discard . t Cm rprnt Ar value Same as the control character .Cm reprint . .El
p The .Nm stty utility exits with a value of 0 if successful, and >0 if an error occurs. .Sh SEE ALSO .Xr termios 4 .Sh STANDARDS The .Nm stty function is expected to be .St -p1003.2 compatible. The flags .Fl e and .Fl f are extensions to the standard.