xref: /netbsd-src/bin/stty/stty.1 (revision b62fc9e20372b08e1785ff6d769312d209fa2005)
1.\"	$NetBSD: stty.1,v 1.39 2010/04/05 16:19:54 joerg 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 December 14, 2009
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 ``\e''
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.Bro Dv _POSIX_VDISABLE Brc . )
377.Pp
378Recognized control-characters:
379.Bd -ragged -offset indent
380.Bl -column character Subscript Description
381.It control- Ta "" Ta ""
382.It character	Subscript	Description
383.It _________	_________	_______________
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 werase Ta Tn VWERASE Ta WERASE No character
389.It kill Ta Tn VKILL Ta KILL No character
390.It reprint Ta Tn VREPRINT Ta REPRINT No character
391.It intr Ta Tn VINTR Ta INTR No character
392.It quit Ta Tn VQUIT Ta QUIT No character
393.It susp Ta Tn VSUSP Ta SUSP No character
394.It dsusp Ta Tn VDSUSP Ta DSUSP No character
395.It start Ta Tn VSTART Ta START No character
396.It stop Ta Tn VSTOP Ta STOP No character
397.It lnext Ta Tn VLNEXT Ta LNEXT No character
398.It status Ta Tn VSTATUS Ta STATUS No character
399.It discard Ta Tn VDISCARD Ta DISCARD No character
400.El
401.Ed
402.It Cm min Ar number
403.It Cm time Ar number
404Set the value of min or time to
405number.
406.Dv MIN
407and
408.Dv TIME
409are used in
410Non-Canonical mode input processing
411(-icanon).
412.El
413.Ss Combination Modes
414.Bl -tag -width Fl
415.It Ar saved settings
416Set the current terminal characteristics to the saved settings
417produced by the
418.Fl g
419option.
420.It Cm evenp No or Cm parity
421Enable parenb and cs7; disable parodd.
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 back to system defaults.
436.It Cm sane
437Resets all modes to reasonable values for interactive terminal use.
438.It Cm insane
439Sets all modes to random values, which are very likely
440.Pq but not guaranteed
441to be unreasonable for interactive terminal use.
442.It Cm tty
443Set the line discipline to the standard terminal line discipline
444.Dv TTYDISC .
445.It Cm crt Pq Fl crt
446Set (disable) all modes suitable for a CRT display device.
447.It Cm kerninfo Pq Fl kerninfo
448Enable (disable) the system generated status line associated with
449processing a
450.Dv STATUS
451character (usually set to ^T).
452The status line consists of the
453system load average, the current command name, its process ID, the
454event the process is waiting on (or the status of the process), the user
455and system times, percent CPU, and current memory usage.
456.It Cm columns Ar number
457The terminal size is recorded as having
458.Ar number
459columns.
460.It Cm cols Ar number
461is an alias for
462.Cm columns .
463.It Cm rows Ar number
464The terminal size is recorded as having
465.Ar number
466rows.
467.It Cm dec
468Set modes suitable for users of Digital Equipment Corporation systems (
469.Dv ERASE ,
470.Dv KILL ,
471and
472.Dv INTR
473characters are set to ^?, ^U, and ^C;
474.Dv ixany
475is disabled, and
476.Dv crt
477is enabled.)
478.It Cm extproc Pq Fl extproc
479If set, this flag indicates that some amount of terminal processing is being
480performed by either the terminal hardware or by the remote side connected
481to a pty.
482.It Cm raw Pq Fl raw
483If set, change the modes of the terminal so that no input or output processing
484is performed.
485If unset, change the modes of the terminal to some reasonable
486state that performs input and output processing.
487Note that since the terminal driver no longer has a single
488.Dv RAW
489bit, it is not possible to intuit what flags were set prior to setting
490.Cm raw .
491This means that unsetting
492.Cm raw
493may not put back all the setting that were previously in effect.
494To set the terminal into a raw state and then accurately restore it, the following
495shell code is recommended:
496.Bd -literal -offset indent
497save_state=$(stty -g)
498stty raw
499\&...
500stty "$save_state"
501.Ed
502.It Cm size
503The size of the terminal is printed as two numbers on a single line,
504first rows, then columns.
505.El
506.Ss Compatibility Modes
507These modes remain for compatibility with the previous version of
508the stty command.
509.Bl -tag -width Fl
510.It Cm all
511Reports all the terminal modes as with
512.Cm stty Fl a
513except that the control characters are printed in a columnar format.
514.It Cm everything
515Same as
516.Cm all .
517.It Cm cooked
518Same as
519.Cm sane .
520.It Cm cbreak
521If set, enables
522.Cm brkint , ixon , imaxbel , opost ,
523.Cm isig , iexten ,
524and
525.Fl icanon .
526If unset, same as
527.Cm sane .
528.It Cm new
529Same as
530.Cm tty .
531.It Cm old
532Same as
533.Cm tty .
534.It Cm newcrt Pq Fl newcrt
535Same as
536.Cm crt .
537.It Cm pass8
538The converse of
539.Cm parity .
540.It Cm tandem Pq Fl tandem
541Same as
542.Cm ixoff .
543.It Cm decctlq Pq Fl decctlq
544The converse of
545.Cm ixany .
546.It Cm crterase Pq Fl crterase
547Same as
548.Cm echoe .
549.It Cm crtbs Pq Fl crtbs
550Same as
551.Cm echoe .
552.It Cm crtkill Pq Fl crtkill
553Same as
554.Cm echoke .
555.It Cm ctlecho Pq Fl ctlecho
556Same as
557.Cm echoctl .
558.It Cm prterase Pq Fl prterase
559Same as
560.Cm echoprt .
561.It Cm litout Pq Fl litout
562The converse of
563.Cm opost .
564.It Cm tabs Pq Fl tabs
565The converse of
566.Cm oxtabs .
567.It Cm brk Ar value
568Same as the control character
569.Cm eol .
570.It Cm flush Ar value
571Same as the control character
572.Cm discard .
573.It Cm rprnt Ar value
574Same as the control character
575.Cm reprint .
576.El
577.Ss Control operations
578These operations are not modes, but rather commands to be performed by
579the tty layer.
580.Bl -tag -width Fl
581.It Cm ostart
582Performs a "start output" operation, as normally done by an
583incoming START character when
584.Cm ixon
585is set.
586.It Cm ostop
587Performs a "stop output" operation, as normally done by an
588incoming STOP character when
589.Cm ixon
590is set.
591.El
592.Sh EXIT STATUS
593The
594.Nm
595utility exits with a value of 0 if successful, and \*[Gt]0 if an error occurs.
596.Sh SEE ALSO
597.Xr termios 4 ,
598.Xr tty 4
599.Sh STANDARDS
600The
601.Nm
602utility is expected to be
603.St -p1003.2
604compatible.
605The flags
606.Fl e
607and
608.Fl f
609are
610extensions to the standard, as are the operands mentioned in the control
611operations section.
612