xref: /original-bsd/bin/stty/stty.1 (revision deff14a8)
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.\" %sccs.include.redist.man%
8.\"
9.\"     @(#)stty.1	8.5 (Berkeley) 06/01/94
10.\"
11.Dd
12.Dt STTY 1
13.Os
14.Sh NAME
15.Nm stty
16.Nd set the options for a terminal device interface
17.Sh SYNOPSIS
18.Nm stty
19.Op Fl a | Fl e | Fl g
20.Op Fl f Ar file
21.Op operands
22.Sh DESCRIPTION
23The
24.Nm stty
25utility sets or reports on terminal
26characteristics for the device that is its standard input.
27If no options or operands are specified, it reports the settings of a subset
28of characteristics as well as additional ones if they differ from their
29default values.
30Otherwise it modifies
31the terminal state according to the specified arguments.
32Some combinations of arguments are mutually
33exclusive on some terminal types.
34.Pp
35The following options are available:
36.Bl -tag -width Ds
37.It Fl a
38Display all the current settings for the terminal to standard output
39as per
40.St -p1003.2 .
41.It Fl e
42Display all the current settings for the terminal to standard output
43in the traditional
44.Tn BSD
45``all'' and ``everything'' formats.
46.It Fl f
47Open and use the terminal named by
48.Ar file
49rather than using standard input.  The file is opened
50using the
51.Dv O_NONBLOCK
52flag of
53.Fn open ,
54making it possible to
55set or display settings on a terminal that might otherwise
56block on the open.
57.It Fl g
58Display all the current settings for the terminal to standard output
59in a form that may be used as an argument to a subsequent invocation of
60.Nm stty
61to restore the current terminal state as per
62.St -p1003.2 .
63.El
64.Pp
65The following arguments are available to set the terminal
66characteristics:
67.Ss Control Modes:
68.Pp
69Control mode flags affect hardware characteristics associated with the
70terminal.  This corresponds to the c_cflag in the termios structure.
71.Bl -tag -width Fl
72.It Cm parenb Pq Fl parenb
73Enable (disable) parity generation
74and detection.
75.It Cm parodd Pq Fl parodd
76Select odd (even) parity.
77.It Cm cs5 cs6 cs7 cs8
78Select character size, if possible.
79.It Ar number
80Set terminal baud rate to the
81number given, if possible.
82If the
83baud rate is set to zero, modem
84control is no longer
85asserted.
86.It Cm ispeed Ar number
87Set terminal input baud rate to the
88number given, if possible.
89If the
90input baud rate is set to zero, the
91input baud rate is set to the
92value of the output baud
93rate.
94.It Cm ospeed Ar number
95Set terminal output baud rate to
96the number given, if possible.
97If
98the output baud rate is set to
99zero, modem control is
100no longer asserted.
101.ne 1i
102.It Cm speed Ar number
103This sets both
104.Cm ispeed
105and
106.Cm ospeed
107to
108.Ar number .
109.It Cm hupcl Pq Fl hupcl
110Stop asserting modem control
111(do not stop asserting modem control) on last close.
112.It Cm hup Pq Fl hup
113Same as hupcl
114.Pq Fl hupcl .
115.It Cm cstopb Pq Fl cstopb
116Use two (one) stop bits per character.
117.It Cm cread Pq Fl cread
118Enable (disable) the receiver.
119.It Cm clocal Pq Fl clocal
120Assume a line without (with) modem
121control.
122.It Cm crtscts Pq Fl crtscts
123Enable RTS/CTS flow control.
124.El
125.Ss Input Modes:
126This corresponds to the c_iflag in the termios structure.
127.Bl -tag -width Fl
128.It Cm ignbrk Pq Fl ignbrk
129Ignore (do not ignore) break on
130input.
131.It Cm brkint Pq Fl brkint
132Signal (do not signal)
133.Dv INTR
134on
135break.
136.It Cm ignpar Pq Fl ignpar
137Ignore (do not ignore) parity
138errors.
139.It Cm parmrk Pq Fl parmrk
140Mark (do not mark) parity errors.
141.It Cm inpck Pq Fl inpck
142Enable (disable) input parity
143checking.
144.It Cm istrip Pq Fl istrip
145Strip (do not strip) input characters
146to seven bits.
147.It Cm inlcr Pq Fl inlcr
148Map (do not map)
149.Dv NL
150to
151.Dv CR
152on input.
153.It Cm igncr Pq Fl igncr
154Ignore (do not ignore)
155.Dv CR
156on input.
157.It Cm icrnl Pq Fl icrnl
158Map (do not map)
159.Dv CR
160to
161.Dv NL
162on input.
163.It Cm ixon Pq Fl ixon
164Enable (disable)
165.Dv START/STOP
166output
167control.
168Output from the system is
169stopped when the system receives
170.Dv STOP
171and started when the system
172receives
173.Dv START ,
174or if
175.Cm ixany
176is set, any character restarts output.
177.ne 1i
178.It Cm ixoff Pq Fl ixoff
179Request that the system send (not
180send)
181.Dv START/STOP
182characters when
183the input queue is nearly
184empty/full.
185.It Cm ixany Pq Fl ixany
186Allow any character (allow only
187.Dv START )
188to restart output.
189.It Cm imaxbel Pq Fl imaxbel
190The system imposes a limit of
191.Dv MAX_INPUT
192(currently 255) characters in the input queue.  If
193.Cm imaxbel
194is set and the input queue limit has been reached,
195subsequent input causes the system to send an ASCII BEL
196character to the output queue (the terminal beeps at you).  Otherwise,
197if
198.Cm imaxbel
199is unset and the input queue is full, the next input character causes
200the entire input and output queues to be discarded.
201.El
202.Ss Output Modes:
203This corresponds to the c_oflag of the termios structure.
204.Bl -tag -width Fl
205.It Cm opost Pq Fl opost
206Post-process output (do not
207post-process output; ignore all other
208output modes).
209.It Cm onlcr Pq Fl onlcr
210Map (do not map)
211.Dv NL
212to
213.DV CR-NL
214on output.
215.It Cm oxtabs Pq Fl oxtabs
216Expand (do not expand) tabs to spaces on output.
217.El
218.Ss Local Modes:
219.Pp
220Local mode flags (lflags) affect various and sundry characteristics of terminal
221processing.
222Historically the term "local" pertained to new job control features
223implemented by Jim Kulp on a
224.Tn Pdp 11/70
225at
226.Tn IIASA .
227Later the driver ran on the first
228.Tn VAX
229at Evans Hall, UC Berkeley, where the job control details
230were greatly modified but the structure definitions and names
231remained essentially unchanged.
232The second interpretation of the 'l' in lflag
233is ``line discipline flag'' which corresponds to the
234.Ar c_lflag
235of the
236.Ar termios
237structure.
238.Bl -tag -width Fl
239.It Cm isig Pq Fl isig
240Enable (disable) the checking of
241characters against the special control
242characters
243.Dv INTR , QUIT ,
244and
245.Dv SUSP .
246.It Cm icanon Pq Fl icanon
247Enable (disable) canonical input
248.Pf ( Dv ERASE
249and
250.Dv KILL
251processing).
252.It Cm iexten Pq Fl iexten
253Enable (disable) any implementation
254defined special control characters
255not currently controlled by icanon,
256isig, or ixon.
257.It Cm echo Pq Fl echo
258Echo back (do not echo back) every
259character typed.
260.It Cm echoe Pq Fl echoe
261The
262.Dv ERASE
263character shall (shall
264not) visually erase the last character
265in the current line from the
266display, if possible.
267.It Cm echok Pq Fl echok
268Echo (do not echo)
269.Dv NL
270after
271.Dv KILL
272character.
273.ne 1i
274.It Cm echoke Pq Fl echoke
275The
276.Dv KILL
277character shall (shall
278not) visually erase the
279the current line from the
280display, if possible.
281.It Cm echonl Pq Fl echonl
282Echo (do not echo)
283.Dv NL ,
284even if echo
285is disabled.
286.It Cm echoctl Pq Fl echoctl
287If
288.Cm echoctl
289is set, echo control characters as ^X.  Otherwise control characters
290echo as themselves.
291.It Cm echoprt Pq Fl echoprt
292For printing terminals. If set, echo erased characters backwards within ``\\''
293and ``/''.  Otherwise, disable this feature.
294.It Cm noflsh Pq Fl noflsh
295Disable (enable) flush after
296.Dv INTR , QUIT , SUSP .
297.It Cm tostop Pq Fl tostop
298Send (do not send)
299.Dv SIGTTOU
300for background output.  This causes background jobs to stop if they attempt
301terminal output.
302.It Cm altwerase Pq Fl altwerase
303Use (do not use) an alternate word erase algorithm when processing
304.Dv WERASE
305characters.
306This alternate algorithm considers sequences of
307alphanumeric/underscores as words.
308It also skips the first preceding character in its classification
309(as a convenience since the one preceding character could have been
310erased with simply an
311.Dv ERASE
312character.)
313.It Cm mdmbuf Pq Fl mdmbuf
314If set, flow control output based on condition of Carrier Detect.  Otherwise
315writes return an error if Carrier Detect is low (and Carrier is not being
316ignored with the
317.Dv CLOCAL
318flag.)
319.It Cm flusho Pq Fl flusho
320Indicates output is (is not) being discarded.
321.It Cm pendin Pq Fl pendin
322Indicates input is (is not) pending after a switch from non-canonical
323to canonical mode and will be re-input when a read becomes pending
324or more input arrives.
325.El
326.Ss Control Characters:
327.Bl -tag -width Fl
328.It Ar control-character Ar string
329Set
330.Ar control-character
331to
332.Ar string .
333If string is a single character,
334the control character is set to
335that character.
336If string is the
337two character sequence "^-" or the
338string "undef" the control character
339is disabled (i.e. set to
340.Pf { Dv _POSIX_VDISABLE Ns } . )
341.Pp
342Recognized control-characters:
343.Bd -ragged -offset indent
344.Bl -column character Subscript
345.It control-
346.It character	Subscript	Description
347.It _________	_________	_______________
348.It eof Ta Tn VEOF	EOF No character
349.It eol Ta Tn VEOL	EOL No character
350.It eol2 Ta Tn VEOL2	EOL2 No character
351.It erase Ta Tn VERASE	ERASE No character
352.It werase Ta Tn VWERASE	WERASE No character
353.It intr Ta Tn VINTR	INTR No character
354.It kill Ta Tn VKILL	KILL No character
355.It quit Ta Tn VQUIT	QUIT No character
356.It susp Ta Tn VSUSP	SUSP No character
357.It start Ta Tn VSTART	START No character
358.It stop Ta Tn VSTOP	STOP No character
359.It dsusp Ta Tn VDSUSP	DSUSP No character
360.It lnext Ta Tn VLNEXT	LNEXT No character
361.It reprint Ta Tn VREPRINT	REPRINT No character
362.It status Ta Tn VSTATUS	STATUS No character
363.El
364.Ed
365.It Cm min Ar number
366.It Cm time Ar number
367Set the value of min or time to
368number.
369.Dv MIN
370and
371.Dv TIME
372are used in
373Non-Canonical mode input processing
374(-icanon).
375.El
376.Ss Combination Modes:
377.Pp
378.Bl -tag -width Fl
379.It Ar saved settings
380Set the current terminal
381characteristics to the saved settings
382produced by the
383.Fl g
384option.
385.It Cm evenp No or Cm parity
386Enable parenb and cs7; disable
387parodd.
388.It Cm oddp
389Enable parenb, cs7, and parodd.
390.It Fl parity , evenp ,  oddp
391Disable parenb, and set cs8.
392.It Cm \&nl Pq Fl \&nl
393Enable (disable) icrnl.
394In addition
395-nl unsets inlcr and igncr.
396.It Cm ek
397Reset
398.Dv ERASE
399and
400.Dv KILL
401characters
402back to system defaults.
403.It Cm sane
404Resets all modes to reasonable values for interactive terminal use.
405.It Cm tty
406Set the line discipline to the standard terminal line discipline
407.Dv TTYDISC .
408.It Cm crt Pq Fl crt
409Set (disable) all modes suitable for a CRT display device.
410.It Cm kerninfo Pq Fl kerninfo
411Enable (disable) the system generated status line associated with
412processing a
413.Dv STATUS
414character (usually set to ^T).  The status line consists of the
415system load average, the current command name, its process ID, the
416event the process is waiting on (or the status of the process), the user
417and system times, percent cpu, and current memory usage.
418.It Cm columns Ar number
419The terminal size is recorded as having
420.Ar number
421columns.
422.It Cm cols Ar number
423is an alias for
424.Cm columns.
425.ne 1i
426.It Cm rows Ar number
427The terminal size is recorded as having
428.Ar number
429rows.
430.It Cm dec
431Set modes suitable for users of Digital Equipment Corporation systems (
432.Dv ERASE ,
433.Dv KILL ,
434and
435.Dv INTR
436characters are set to ^?, ^U, and ^C;
437.Dv ixany
438is disabled, and
439.Dv crt
440is enabled.)
441.It Cm extproc Pq Fl extproc
442If set, this flag indicates that some amount of terminal processing is being
443performed by either the terminal hardware or by the remote side connected
444to a pty.
445.It Cm raw Pq Fl raw
446If set, change the modes of the terminal so that no input or output processing
447is performed. If unset, change the modes of the terminal to some reasonable
448state that performs input and output processing.  Note that since the
449terminal driver no longer has a single
450.Dv RAW
451bit, it is not possible to intuit what flags were set prior to setting
452.Cm raw .
453This means that unsetting
454.Cm raw
455may not put back all the setting that were previously in effect.
456To set the terminal into a raw state and then accurately restore it, the following
457shell code is recommended:
458.nf
459
460save_state=$(stty -g)
461stty raw
462\&...
463stty "$save_state"
464
465.fi
466.It Cm size
467The size of the terminal is printed as two numbers on a single line,
468first rows, then columns.
469.El
470.Ss Compatibility Modes:
471.Pp
472These modes remain for compatibility with the previous version of
473the stty command.
474.Bl -tag -width Fl
475.It Cm all
476Reports all the terminal modes as with
477.Cm stty Fl a
478except that the control characters are printed in a columnar format.
479.It Cm everything
480Same as
481.Cm all .
482.It Cm cooked
483Same as
484.Cm sane .
485.It Cm cbreak
486If set, enables
487.Cm brkint , ixon , imaxbel , opost ,
488.Cm isig , iexten ,
489and
490.Cm Fl icanon .
491If unset, same as
492.Cm sane .
493.It Cm new
494Same as
495.Cm tty .
496.It Cm old
497Same as
498.Cm tty .
499.It Cm newcrt Pq Fl newcrt
500Same as
501.Cm crt .
502.It Cm pass8
503The converse of
504.Cm parity .
505.It Cm tandem Pq Fl tandem
506Same as
507.Cm ixoff .
508.It Cm decctlq Pq Fl decctlq
509The converse of
510.Cm ixany .
511.ne 1i
512.It Cm crterase Pq Fl crterase
513Same as
514.Cm echoe .
515.It Cm crtbs Pq Fl crtbs
516Same as
517.Cm echoe .
518.It Cm crtkill Pq Fl crtkill
519Same as
520.Cm echoke .
521.It Cm ctlecho Pq Fl ctlecho
522Same as
523.Cm echoctl .
524.It Cm prterase Pq Fl prterase
525Same as
526.Cm echoprt .
527.It Cm litout Pq Fl litout
528The converse of
529.Cm opost .
530.It Cm tabs Pq Fl tabs
531The converse of
532.Cm tabs .
533.It Cm brk Ar value
534Same as the control character
535.Cm eol .
536.It Cm flush Ar value
537Same as the control character
538.Cm discard .
539.It Cm rprnt Ar value
540Same as the control character
541.Cm reprint .
542.El
543.Pp
544The
545.Nm stty
546utility exits with a value of 0 if successful, and >0 if an error occurs.
547.Sh SEE ALSO
548.Xr termios 4
549.Sh STANDARDS
550The
551.Nm stty
552function is expected to be
553.St -p1003.2
554compatible.  The flags
555.Fl e
556and
557.Fl f
558are
559extensions to the standard.
560