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