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