5

The documentation says the following:

[-]opost postprocess output

I don't understand what this means. I have tried to disable this flag to see what it does:

stty -opost -F /dev/pts/0

And I have typed the ls command, and the result had the first line indented:

enter image description here

I still don't get what this flag does!

Kusalananda
  • 320,670
  • 36
  • 633
  • 936
user259241
  • 51
  • 1
  • 2

1 Answers1

6

stty -opost deactivates post-processing output. For example, normally sending a <LF> (U+00A0) character to the terminal will automatically insert a <CR> (U+000D) character, to make the cursor go to the beginning of the next line. Most importantly, setting -opost deactivates all processing of output, irrespective of any other output options.

See the manual page for stty(1) for details.

Kusalananda
  • 320,670
  • 36
  • 633
  • 936
AlexP
  • 10,217
  • 32
  • 41
  • So if for example the `ocrnl` is set, and I disable the `opost` flag, then the `ocrnl` flag will be ignored (also all other similar flags responsible for processing of output will be ignored)? – user259241 Nov 06 '17 at 17:58
  • Why not try it out? `stty -opost ocrnl; echo -e 'aaa\nbbb'; stty sane` – AlexP Nov 06 '17 at 18:11
  • While this is useful information, it is certainly not a comprehensive answer. E.g. I discovered that `opost` controls whether or not an LF after a full line of text is suppressed. E.g. for an 80 chars wide terminal, outputting 80 dots followed by an LF will not cause a blank line to appear if `opost` is set. – Arne Vogel Sep 01 '18 at 19:13
  • 3
    "deactivates the output processing" and the manual page all give the same (useless) information: That it suppresses output processing. The question is about what that output processing is. – toolforger Apr 02 '19 at 05:23
  • The [IBM documentation](https://www.ibm.com/docs/en/zos/2.3.0?topic=functions-tcsetattr-set-attributes-terminal) gives a bit more detail. For options like `ONLCR` it says "If OPOST and ONLCR are set...". So turning off OPOST turns off ONLCR even if the ONLCR bit is set. Same goes for `ONOCR`, `OCRNL`, and `ONLRET`. – Darryl Mar 15 '23 at 18:01