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