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