NetBSD/bin/stty/stty.1

636 lines
16 KiB
Groff
Raw Normal View History

2012-06-20 18:19:39 +04:00
.\" $NetBSD: stty.1,v 1.41 2012/06/20 14:19:39 wiz Exp $
1995-03-21 12:01:59 +03:00
.\"
1994-09-20 08:52:02 +04:00
.\" Copyright (c) 1990, 1993, 1994
.\" The Regents of the University of California. All rights reserved.
1993-03-21 12:45:37 +03:00
.\"
.\" 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. Neither the name of the University nor the names of its contributors
1993-03-21 12:45:37 +03:00
.\" 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.
.\"
1995-09-07 10:57:11 +04:00
.\" @(#)stty.1 8.5 (Berkeley) 6/1/94
1993-03-22 11:04:00 +03:00
.\"
.Dd June 16, 2012
1993-03-21 12:45:37 +03:00
.Dt STTY 1
.Os
.Sh NAME
.Nm stty
.Nd set options for a terminal device interface
1993-03-21 12:45:37 +03:00
.Sh SYNOPSIS
1997-10-20 12:50:59 +04:00
.Nm
1993-03-21 12:45:37 +03:00
.Op Fl a | Fl e | Fl g
.Op Fl f Ar file
.Op operand ...
1993-03-21 12:45:37 +03:00
.Sh DESCRIPTION
1994-09-20 08:52:02 +04:00
The
1997-10-20 12:50:59 +04:00
.Nm
1993-03-21 12:45:37 +03:00
utility sets or reports on terminal
characteristics for the device that is its standard input.
1994-09-20 08:52:02 +04:00
If no options or operands are specified, it reports the settings of a subset
1993-03-21 12:45:37 +03:00
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.
.Pp
The following options are available:
.Bl -tag -width XfXfileXX
1993-03-21 12:45:37 +03:00
.It Fl a
1994-09-20 08:52:02 +04:00
Display all the current settings for the terminal to standard output
as per
1993-03-21 12:45:37 +03:00
.St -p1003.2 .
.It Fl e
1994-09-20 08:52:02 +04:00
Display all the current settings for the terminal to standard output
1993-03-21 12:45:37 +03:00
in the traditional
.Bx
.Dq all
and
.Dq everything
formats.
.It Fl f Ar file
1994-09-20 08:52:02 +04:00
Open and use the terminal named by
.Ar file
rather than using standard input.
The file is opened using the
1994-09-20 08:52:02 +04:00
.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.
1993-03-21 12:45:37 +03:00
.It Fl g
1994-09-20 08:52:02 +04:00
Display all the current settings for the terminal to standard output
1993-03-21 12:45:37 +03:00
in a form that may be used as an argument to a subsequent invocation of
1997-10-20 12:50:59 +04:00
.Nm
1994-09-20 08:52:02 +04:00
to restore the current terminal state as per
.St -p1003.2 .
1993-03-21 12:45:37 +03:00
.El
.Pp
The following arguments are available to set the terminal
characteristics:
.Ss Control Modes
1994-09-20 08:52:02 +04:00
Control mode flags affect hardware characteristics associated with the
terminal.
This corresponds to the
.Fa c_cflag
of the
.Xr termios 4
structure.
1993-03-21 12:45:37 +03:00
.Bl -tag -width Fl
.It Cm parenb Pq Fl parenb
Enable (disable) parity generation
and detection.
.It Cm parodd Pq Fl parodd
Select odd (even) parity.
.It Cm cs5 cs6 cs7 cs8
Select character size, if possible.
.It Ar number
Set terminal baud rate to
.Ar number ,
if possible.
1993-03-21 12:45:37 +03:00
If the
baud rate is set to zero, modem
control is no longer
asserted.
.It Cm ispeed Ar number
Set terminal input baud rate to
.Ar number ,
if possible.
1993-03-21 12:45:37 +03:00
If the
input baud rate is set to zero, the
input baud rate is set to the
value of the output baud
rate.
.It Cm ospeed Ar number
Set terminal output baud rate to
.Ar number ,
if possible.
1993-03-21 12:45:37 +03:00
If
the output baud rate is set to
zero, modem control is
no longer asserted.
1994-09-20 08:52:02 +04:00
.It Cm speed Ar number
This sets both
.Cm ispeed
and
.Cm ospeed
to
.Ar number .
1993-03-21 12:45:37 +03:00
.It Cm hupcl Pq Fl hupcl
Stop asserting modem control
(do not stop asserting modem control) on last close.
.It Cm hup Pq Fl hup
Same as hupcl
.Pq Fl hupcl .
.It Cm cstopb Pq Fl cstopb
Use two (one) stop bits per character.
.It Cm cread Pq Fl cread
Enable (disable) the receiver.
.It Cm clocal Pq Fl clocal
Assume a line without (with) modem
control.
1994-09-20 08:52:02 +04:00
.It Cm crtscts Pq Fl crtscts
Enable RTS/CTS flow control.
.It Cm cdtrcts Pq Fl cdtrcts
Enable DTR/CTS flow control (if supported).
1994-09-20 08:52:02 +04:00
.El
.Ss Input Modes
This corresponds to the
.Fa c_iflag
of the
.Xr termios 4
structure.
1994-09-20 08:52:02 +04:00
.Bl -tag -width Fl
1993-03-21 12:45:37 +03:00
.It Cm ignbrk Pq Fl ignbrk
Ignore (do not ignore) break on
input.
.It Cm brkint Pq Fl brkint
Signal (do not signal)
.Dv INTR
on
break.
.It Cm ignpar Pq Fl ignpar
Ignore (do not ignore) parity
errors.
.It Cm parmrk Pq Fl parmrk
Mark (do not mark) parity errors.
.It Cm inpck Pq Fl inpck
Enable (disable) input parity
checking.
.It Cm istrip Pq Fl istrip
Strip (do not strip) input characters
to seven bits.
.It Cm inlcr Pq Fl inlcr
Map (do not map)
.Dv NL
to
.Dv CR
on input.
.It Cm igncr Pq Fl igncr
Ignore (do not ignore)
.Dv CR
on input.
.It Cm icrnl Pq Fl icrnl
Map (do not map)
.Dv CR
to
.Dv NL
on input.
.It 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
1994-09-20 08:52:02 +04:00
.Dv START ,
or if
.Cm ixany
is set, any character restarts output.
1993-03-21 12:45:37 +03:00
.It Cm ixoff Pq Fl ixoff
Request that the system send (not
send)
.Dv START/STOP
characters when
the input queue is nearly
empty/full.
1994-09-20 08:52:02 +04:00
.It Cm ixany Pq Fl ixany
Allow any character (allow only
.Dv START )
to restart output.
.It Cm imaxbel Pq Fl imaxbel
The system imposes a limit of
.Dv MAX_INPUT
(currently 255) characters in the input queue.
If
1994-09-20 08:52:02 +04:00
.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,
1994-09-20 08:52:02 +04:00
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
.Fa c_oflag
of the
.Xr termios 4
structure.
1994-09-20 08:52:02 +04:00
.Bl -tag -width Fl
1993-03-21 12:45:37 +03:00
.It Cm opost Pq Fl opost
Post-process output (do not
post-process output; ignore all other
output modes).
1994-09-20 08:52:02 +04:00
.It Cm onlcr Pq Fl onlcr
Map (do not map)
.Dv NL
to
.Dv CR-NL
1994-09-20 08:52:02 +04:00
on output.
.It Cm ocrnl Pq Fl ocrnl
Map (do not map)
.Dv CR
to
.Dv NL
on output.
1994-09-20 08:52:02 +04:00
.It Cm oxtabs Pq Fl oxtabs
Expand (do not expand) tabs to spaces on output.
.It Cm onocr Pq Fl onocr
Do not (do) output CRs at column zero.
.It Cm onlret Pq Fl onlret
On the terminal NL performs (does not perform) the CR function.
1994-09-20 08:52:02 +04:00
.El
.Ss Local Modes
1994-09-20 08:52:02 +04:00
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
2003-03-31 00:52:51 +04:00
.Tn PDP Ns -11/70
1994-09-20 08:52:02 +04:00
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
.Sq l
in lflag
is
.Dq line discipline flag ,
which corresponds to the
.Fa c_lflag
1994-09-20 08:52:02 +04:00
of the
.Xr termios 4
1994-09-20 08:52:02 +04:00
structure.
.Bl -tag -width Fl
1993-03-21 12:45:37 +03:00
.It Cm isig Pq Fl isig
Enable (disable) the checking of
characters against the special control
characters
.Dv INTR , QUIT ,
and
.Dv SUSP .
.It Cm icanon Pq Fl icanon
Enable (disable) canonical input
.Dv ( ERASE
1993-03-21 12:45:37 +03:00
and
.Dv KILL
processing).
.It Cm iexten Pq Fl iexten
Enable (disable) any implementation
defined special control characters
not currently controlled by icanon,
isig, or ixon.
.It Cm echo Pq Fl echo
Echo back (do not echo back) every
character typed.
.It 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.
.It Cm echok Pq Fl echok
Echo (do not echo)
.Dv NL
after
.Dv KILL
character.
1994-09-20 08:52:02 +04:00
.It Cm echoke Pq Fl echoke
The
.Dv KILL
character shall (shall
1996-11-11 02:58:22 +03:00
not) visually erase
1994-09-20 08:52:02 +04:00
the current line from the
display, if possible.
1993-03-21 12:45:37 +03:00
.It Cm echonl Pq Fl echonl
Echo (do not echo)
.Dv NL ,
even if echo
is disabled.
1994-09-20 08:52:02 +04:00
.It Cm echoctl Pq Fl echoctl
If
.Cm echoctl
is set, echo control characters as ^X.
Otherwise control characters echo as themselves.
1994-09-20 08:52:02 +04:00
.It Cm echoprt Pq Fl echoprt
For printing terminals.
If set, echo erased characters backwards within
.Dq \e
and
.Dq / .
Otherwise, disable this feature.
1993-03-21 12:45:37 +03:00
.It Cm noflsh Pq Fl noflsh
Disable (enable) flush after
.Dv INTR , QUIT , SUSP .
1994-09-20 08:52:02 +04:00
.It 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.
1994-09-20 08:52:02 +04:00
.It Cm altwerase Pq Fl altwerase
1997-03-08 16:26:20 +03:00
Use (do not use) an alternative word erase algorithm when processing
1994-09-20 08:52:02 +04:00
.Dv WERASE
characters.
1997-03-08 16:26:20 +03:00
This alternative algorithm considers sequences of
1994-09-20 08:52:02 +04:00
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).
1994-09-20 08:52:02 +04:00
.It 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
1994-09-20 08:52:02 +04:00
.Dv CLOCAL
flag).
1994-09-20 08:52:02 +04:00
.It Cm flusho Pq Fl flusho
Indicates output is (is not) being discarded.
.It 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
1994-09-20 08:52:02 +04:00
.Bl -tag -width Fl
.It Ar control-character Ar string
Set
.Ar control-character
to string
1994-09-20 08:52:02 +04:00
.Ar string .
If the string is a single character,
then the control character is set to
1993-03-21 12:45:37 +03:00
that character.
If the string is the
1993-03-21 12:45:37 +03:00
two character sequence "^-" or the
string "undef", then the control character
is disabled (i.e., set to
.Bro Dv _POSIX_VDISABLE Brc ) .
1993-03-21 12:45:37 +03:00
.Pp
Recognized control characters:
1993-03-21 12:45:37 +03:00
.Bd -ragged -offset indent
2009-03-15 15:01:24 +03:00
.Bl -column character Subscript Description
.It control- Ta "" Ta ""
1993-03-21 12:45:37 +03:00
.It character Subscript Description
.It _________ _________ _______________
2009-03-15 15:01:24 +03:00
.It eof Ta Tn VEOF Ta EOF No character
.It eol Ta Tn VEOL Ta EOL No character
.It eol2 Ta Tn VEOL2 Ta EOL2 No character
.It erase Ta Tn VERASE Ta ERASE No character
.It werase Ta Tn VWERASE Ta WERASE No character
.It kill Ta Tn VKILL Ta KILL No character
.It reprint Ta Tn VREPRINT Ta REPRINT No character
.It intr Ta Tn VINTR Ta INTR No character
.It quit Ta Tn VQUIT Ta QUIT No character
.It susp Ta Tn VSUSP Ta SUSP No character
.It dsusp Ta Tn VDSUSP Ta DSUSP No character
.It start Ta Tn VSTART Ta START No character
.It stop Ta Tn VSTOP Ta STOP No character
.It lnext Ta Tn VLNEXT Ta LNEXT No character
.It status Ta Tn VSTATUS Ta STATUS No character
.It discard Ta Tn VDISCARD Ta DISCARD No character
1993-03-21 12:45:37 +03:00
.El
.Ed
.It Cm min Ar number
.It Cm time Ar number
Set the value of min or time to
.Ar number .
1993-03-21 12:45:37 +03:00
.Dv MIN
and
.Dv TIME
are used in
Non-Canonical mode input processing
(-icanon).
1994-09-20 08:52:02 +04:00
.El
.Ss Combination Modes
1994-09-20 08:52:02 +04:00
.Bl -tag -width Fl
.It Ar saved settings
Set the current terminal characteristics to the saved settings
1994-09-20 08:52:02 +04:00
produced by the
.Fl g
option.
1993-03-21 12:45:37 +03:00
.It Cm evenp No or Cm parity
Enable parenb and cs7; disable parodd.
1993-03-21 12:45:37 +03:00
.It Cm oddp
Enable parenb, cs7, and parodd.
.It Fl parity , evenp , oddp
Disable parenb, and set cs8.
1994-09-20 08:52:02 +04:00
.It Cm \&nl Pq Fl \&nl
1993-03-21 12:45:37 +03:00
Enable (disable) icrnl.
In addition
-nl unsets inlcr and igncr.
.It Cm ek
Reset
.Dv ERASE
and
.Dv KILL
characters back to system defaults.
1993-03-21 12:45:37 +03:00
.It Cm sane
Resets all modes to reasonable values for interactive terminal use.
.It Cm insane
Sets all modes to random values, which are very likely
.Pq but not guaranteed
to be unreasonable for interactive terminal use.
1993-03-21 12:45:37 +03:00
.It Cm tty
Set the line discipline to the standard terminal line discipline
.Dv TTYDISC .
1994-09-20 08:52:02 +04:00
.It Cm crt Pq Fl crt
Set (disable) all modes suitable for a CRT display device.
.It 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
1994-09-20 08:52:02 +04:00
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
2004-02-13 12:55:51 +03:00
and system times, percent CPU, and current memory usage.
1994-09-20 08:52:02 +04:00
.It Cm columns Ar number
The terminal size is recorded as having
.Ar number
columns.
.It Cm cols Ar number
An alias for
.Cm columns .
1994-09-20 08:52:02 +04:00
.It Cm rows Ar number
The terminal size is recorded as having
.Ar number
rows.
.It Cm dec
Set modes suitable for users of Digital Equipment Corporation systems
2012-06-20 18:19:39 +04:00
.Dv ( ERASE ,
1994-09-20 08:52:02 +04:00
.Dv KILL ,
and
.Dv INTR
characters are set to ^?, ^U, and ^C;
.Dv ixany
is disabled, and
.Dv crt
is enabled).
1994-09-20 08:52:02 +04:00
.It 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.
.It 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
1994-09-20 08:52:02 +04:00
.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:
.Bd -literal -offset indent
1994-09-20 08:52:02 +04:00
save_state=$(stty -g)
stty raw
\&...
stty "$save_state"
.Ed
1994-09-20 08:52:02 +04:00
.It Cm size
The size of the terminal is printed as two numbers on a single line,
first rows, then columns.
.El
.Ss Compatibility Modes
1994-09-20 08:52:02 +04:00
These modes remain for compatibility with the previous version of
the
.Nm
utility.
1994-09-20 08:52:02 +04:00
.Bl -tag -width Fl
.It Cm all
Reports all the terminal modes as with
.Cm stty Fl a
except that the control characters are printed in a columnar format.
.It Cm everything
Same as
.Cm all .
.It Cm cooked
Same as
.Cm sane .
.It Cm cbreak
If set, enables
.Cm brkint , ixon , imaxbel , opost ,
.Cm isig , iexten ,
and
2003-07-01 14:24:41 +04:00
.Fl icanon .
1994-09-20 08:52:02 +04:00
If unset, same as
.Cm sane .
.It Cm new
Same as
.Cm tty .
.It Cm old
Same as
.Cm tty .
.It Cm newcrt Pq Fl newcrt
Same as
.Cm crt .
.It Cm pass8
The converse of
.Cm parity .
.It Cm tandem Pq Fl tandem
Same as
.Cm ixoff .
.It Cm decctlq Pq Fl decctlq
The converse of
.Cm ixany .
.It Cm crterase Pq Fl crterase
Same as
.Cm echoe .
.It Cm crtbs Pq Fl crtbs
Same as
.Cm echoe .
.It Cm crtkill Pq Fl crtkill
Same as
.Cm echoke .
.It Cm ctlecho Pq Fl ctlecho
Same as
.Cm echoctl .
.It Cm prterase Pq Fl prterase
Same as
.Cm echoprt .
.It Cm litout Pq Fl litout
The converse of
.Cm opost .
.It Cm tabs Pq Fl tabs
The converse of
.Cm oxtabs .
1994-09-20 08:52:02 +04:00
.It Cm brk Ar value
Same as the control character
.Cm eol .
.It Cm flush Ar value
Same as the control character
.Cm discard .
.It Cm rprnt Ar value
Same as the control character
.Cm reprint .
1993-03-21 12:45:37 +03:00
.El
.Ss Control operations
1999-01-14 02:55:26 +03:00
These operations are not modes, but rather commands to be performed by
the tty layer.
.Bl -tag -width Fl
.It Cm ostart
Performs a "start output" operation, as normally done by an
incoming START character when
.Cm ixon
is set.
.It Cm ostop
Performs a "stop output" operation, as normally done by an
incoming STOP character when
.Cm ixon
is set.
.El
.Sh EXIT STATUS
.Ex -std
1993-03-21 12:45:37 +03:00
.Sh SEE ALSO
.Xr termios 4 ,
.Xr tty 4
1993-03-21 12:45:37 +03:00
.Sh STANDARDS
The
1997-10-20 12:50:59 +04:00
.Nm
utility is expected to be
1993-03-21 12:45:37 +03:00
.St -p1003.2
compatible.
The
1994-09-20 08:52:02 +04:00
.Fl e
and
.Fl f
flags are
1999-01-14 02:55:26 +03:00
extensions to the standard, as are the operands mentioned in the control
operations section.