xref: /dragonfly/bin/stty/stty.1 (revision 2cd2d2b5)
1.\" Copyright (c) 1990, 1993, 1994
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" the Institute of Electrical and Electronics Engineers, Inc.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\" 1. Redistributions of source code must retain the above copyright
11.\"    notice, this list of conditions and the following disclaimer.
12.\" 2. Redistributions in binary form must reproduce the above copyright
13.\"    notice, this list of conditions and the following disclaimer in the
14.\"    documentation and/or other materials provided with the distribution.
15.\" 3. All advertising materials mentioning features or use of this software
16.\"    must display the following acknowledgement:
17.\"	This product includes software developed by the University of
18.\"	California, Berkeley and its contributors.
19.\" 4. Neither the name of the University nor the names of its contributors
20.\"    may be used to endorse or promote products derived from this software
21.\"    without specific prior written permission.
22.\"
23.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33.\" SUCH DAMAGE.
34.\"
35.\"     @(#)stty.1	8.4 (Berkeley) 4/18/94
36.\" $FreeBSD: src/bin/stty/stty.1,v 1.13.2.6 2001/12/14 14:22:09 ru Exp $
37.\" $DragonFly: src/bin/stty/stty.1,v 1.3 2003/10/13 21:24:26 dillon Exp $
38.\"
39.Dd April 18, 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 indent
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:
96.Pp
97Control mode flags affect hardware characteristics associated with the
98terminal.  This corresponds to the c_cflag in the termios structure.
99.Bl -tag -width Fl
100.It Cm parenb Pq Fl parenb
101Enable (disable) parity generation
102and detection.
103.It Cm parodd Pq Fl parodd
104Select odd (even) parity.
105.It Cm cs5 cs6 cs7 cs8
106Select character size, if possible.
107.It Ar number
108Set terminal baud rate to the
109number given, if possible.
110If the
111baud rate is set to zero, modem
112control is no longer
113asserted.
114.It Cm ispeed Ar number
115Set terminal input baud rate to the
116number given, if possible.
117If the
118input baud rate is set to zero, the
119input baud rate is set to the
120value of the output baud
121rate.
122.It Cm ospeed Ar number
123Set terminal output baud rate to
124the number given, if possible.
125If
126the output baud rate is set to
127zero, modem control is
128no longer asserted.
129.It Cm speed Ar number
130This sets both
131.Cm ispeed
132and
133.Cm ospeed
134to
135.Ar number .
136.It Cm hupcl Pq Fl hupcl
137Stop asserting modem control
138(do not stop asserting modem control) on last close.
139.It Cm hup Pq Fl hup
140Same as hupcl
141.Pq Fl hupcl .
142.It Cm cstopb Pq Fl cstopb
143Use two (one) stop bits per character.
144.It Cm cread Pq Fl cread
145Enable (disable) the receiver.
146.It Cm clocal Pq Fl clocal
147Assume a line without (with) modem
148control.
149.It Cm crtscts Pq Fl crtscts
150Enable (disable) RTS/CTS flow control.
151.El
152.Ss Input Modes:
153This corresponds to the c_iflag in the termios structure.
154.Bl -tag -width Fl
155.It Cm ignbrk Pq Fl ignbrk
156Ignore (do not ignore) break on
157input.
158.It Cm brkint Pq Fl brkint
159Signal (do not signal)
160.Dv INTR
161on
162break.
163.It Cm ignpar Pq Fl ignpar
164Ignore (do not ignore) characters with parity
165errors.
166.It Cm parmrk Pq Fl parmrk
167Mark (do not mark) characters with parity errors.
168.It Cm inpck Pq Fl inpck
169Enable (disable) input parity
170checking.
171.It Cm istrip Pq Fl istrip
172Strip (do not strip) input characters
173to seven bits.
174.It Cm inlcr Pq Fl inlcr
175Map (do not map)
176.Dv NL
177to
178.Dv CR
179on input.
180.It Cm igncr Pq Fl igncr
181Ignore (do not ignore)
182.Dv CR
183on input.
184.It Cm icrnl Pq Fl icrnl
185Map (do not map)
186.Dv CR
187to
188.Dv NL
189on input.
190.It Cm ixon Pq Fl ixon
191Enable (disable)
192.Dv START/STOP
193output
194control.
195Output from the system is
196stopped when the system receives
197.Dv STOP
198and started when the system
199receives
200.Dv START ,
201or if
202.Cm ixany
203is set, any character restarts output.
204.It Cm ixoff Pq Fl ixoff
205Request that the system send (not
206send)
207.Dv START/STOP
208characters when
209the input queue is nearly
210empty/full.
211.It Cm ixany Pq Fl ixany
212Allow any character (allow only
213.Dv START )
214to restart output.
215.It Cm imaxbel Pq Fl imaxbel
216The system imposes a limit of
217.Dv MAX_INPUT
218(currently 255) characters in the input queue.  If
219.Cm imaxbel
220is set and the input queue limit has been reached,
221subsequent input causes the system to send an ASCII BEL
222character to the output queue (the terminal beeps at you).  Otherwise,
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:
255.Pp
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 the
314current 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.
328If set, echo erased characters backwards within ``\\''
329and ``/''.  Otherwise, 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.  This causes background jobs to stop if they attempt
337terminal output.
338.It Cm altwerase Pq Fl altwerase
339Use (do not use) an alternate word erase algorithm when processing
340.Dv WERASE
341characters.
342This alternate 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.  Otherwise
351writes return an error if Carrier Detect is low (and Carrier is not being
352ignored 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 Ta Subscript Ta Description
383.It _________ Ta _________ Ta _______________
384.It eof Ta Tn VEOF Ta EOF No character
385.It eol Ta Tn VEOL Ta EOL No character
386.It eol2 Ta Tn VEOL2 Ta EOL2 No character
387.It erase Ta Tn VERASE Ta ERASE No character
388.It erase2 Ta Tn VERASE2 Ta ERASE2 No character
389.It werase Ta Tn VWERASE Ta WERASE No character
390.It intr Ta Tn VINTR Ta INTR No character
391.It kill Ta Tn VKILL Ta KILL No character
392.It quit Ta Tn VQUIT Ta QUIT No character
393.It susp Ta Tn VSUSP Ta SUSP No character
394.It start Ta Tn VSTART Ta START No character
395.It stop Ta Tn VSTOP Ta STOP No character
396.It dsusp Ta Tn VDSUSP Ta DSUSP No character
397.It lnext Ta Tn VLNEXT Ta LNEXT No character
398.It reprint Ta Tn VREPRINT Ta REPRINT No character
399.It status Ta Tn VSTATUS Ta STATUS No character
400.It ckpt Ta Tn VCHECKPT Ta CKPT No character
401.El
402.Ed
403.It Cm min Ar number
404.It Cm time Ar number
405Set the value of min or time to
406number.
407.Dv MIN
408and
409.Dv TIME
410are used in
411Non-Canonical mode input processing
412(-icanon).
413.El
414.Ss Combination Modes:
415.Pp
416.Bl -tag -width Fl
417.It Ar saved settings
418Set the current terminal
419characteristics to the saved settings
420produced by the
421.Fl g
422option.
423.It Cm evenp No or Cm parity
424Enable parenb and cs7; disable
425parodd.
426.It Cm oddp
427Enable parenb, cs7, and parodd.
428.It Fl parity , evenp ,  oddp
429Disable parenb, and set cs8.
430.It Cm \&nl Pq Fl \&nl
431Enable (disable) icrnl.
432In addition
433-nl unsets inlcr and igncr.
434.It Cm ek
435Reset
436.Dv ERASE ,
437.Dv ERASE2 ,
438and
439.Dv KILL
440characters
441back to system defaults.
442.It Cm sane
443Resets all modes to reasonable values for interactive terminal use.
444.It Cm tty
445Set the line discipline to the standard terminal line discipline
446.Dv TTYDISC .
447.It Cm crt Pq Fl crt
448Set (disable) all modes suitable for a CRT display device.
449.It Cm kerninfo Pq Fl kerninfo
450Enable (disable) the system generated status line associated with
451processing a
452.Dv STATUS
453character (usually set to ^T).  The status line consists of the
454system load average, the current command name, its process ID, the
455event the process is waiting on (or the status of the process), the user
456and system times, percent cpu, and current memory usage.
457.It Cm columns Ar number
458The terminal size is recorded as having
459.Ar number
460columns.
461.It Cm cols Ar number
462is an alias for
463.Cm columns .
464.It Cm rows Ar number
465The terminal size is recorded as having
466.Ar number
467rows.
468.It Cm dec
469Set modes suitable for users of Digital Equipment Corporation systems
470.Dv ( ERASE ,
471.Dv KILL ,
472and
473.Dv INTR
474characters are set to ^?, ^U, and ^C;
475.Dv ixany
476is disabled, and
477.Dv crt
478is enabled.)
479.It Cm extproc Pq Fl extproc
480If set, this flag indicates that some amount of terminal processing is being
481performed by either the terminal hardware or by the remote side connected
482to a pty.
483.It Cm raw Pq Fl raw
484If set, change the modes of the terminal so that no input or output processing
485is performed.
486If unset, change the modes of the terminal to some reasonable
487state that performs input and output processing.  Note that since the
488terminal driver no longer has a single
489.Dv RAW
490bit, it is not possible to intuit what flags were set prior to setting
491.Cm raw .
492This means that unsetting
493.Cm raw
494may not put back all the setting that were previously in effect.
495To set the terminal into a raw state and then accurately restore it, the following
496shell code is recommended:
497.Bd -literal
498save_state=$(stty -g)
499stty raw
500\&...
501stty "$save_state"
502.Ed
503.It Cm size
504The size of the terminal is printed as two numbers on a single line,
505first rows, then columns.
506.El
507.Ss Compatibility Modes:
508.Pp
509These modes remain for compatibility with the previous version of
510the
511.Nm
512command.
513.Bl -tag -width Fl
514.It Cm all
515Reports all the terminal modes as with
516.Cm stty Fl a
517except that the control characters are printed in a columnar format.
518.It Cm everything
519Same as
520.Cm all .
521.It Cm cooked
522Same as
523.Cm sane .
524.It Cm cbreak
525If set, enables
526.Cm brkint , ixon , imaxbel , opost ,
527.Cm isig , iexten ,
528and
529.Fl icanon .
530If unset, same as
531.Cm sane .
532.It Cm new
533Same as
534.Cm tty .
535.It Cm old
536Same as
537.Cm tty .
538.It Cm newcrt Pq Fl newcrt
539Same as
540.Cm crt .
541.It Cm pass8
542The converse of
543.Cm parity .
544.It Cm tandem Pq Fl tandem
545Same as
546.Cm ixoff .
547.It Cm decctlq Pq Fl decctlq
548The converse of
549.Cm ixany .
550.It Cm crterase Pq Fl crterase
551Same as
552.Cm echoe .
553.It Cm crtbs Pq Fl crtbs
554Same as
555.Cm echoe .
556.It Cm crtkill Pq Fl crtkill
557Same as
558.Cm echoke .
559.It Cm ctlecho Pq Fl ctlecho
560Same as
561.Cm echoctl .
562.It Cm prterase Pq Fl prterase
563Same as
564.Cm echoprt .
565.It Cm litout Pq Fl litout
566The converse of
567.Cm opost .
568.It Cm tabs Pq Fl tabs
569The converse of
570.Cm oxtabs .
571.It Cm brk Ar value
572Same as the control character
573.Cm eol .
574.It Cm flush Ar value
575Same as the control character
576.Cm discard .
577.It Cm rprnt Ar value
578Same as the control character
579.Cm reprint .
580.El
581.Sh DIAGNOSTICS
582.Ex -std
583.Sh SEE ALSO
584.Xr termios 4
585.Sh STANDARDS
586The
587.Nm
588utility is expected to be
589.St -p1003.2
590compatible.  The flags
591.Fl e
592and
593.Fl f
594are
595extensions to the standard.
596