All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Branch <simonmbranch@gmail.com>
To: linux-man@vger.kernel.org
Cc: alx.manpages@gmail.com, mtk.manpages@gmail.com,
	Simon Branch <simonmbranch@gmail.com>
Subject: [PATCH] termios.3: Clarify ONLRET
Date: Sat,  1 Jan 2022 14:55:23 -0800	[thread overview]
Message-ID: <20220101225523.11689-1-simonmbranch@gmail.com> (raw)

While perusing various termios(3) and termios(4) manpages, I noticed the
following inconsistency for ONLRET.  FreeBSD and NetBSD say this:

   If ONLRET is set, the NL character is assumed to do the carriage-return
   function; the column pointer will be set to 0.

OpenBSD says this:

   If ONLRET is set, NL also performs CR on output, and reset current column
   to 0.

POSIX says this:

   NL performs CR function.

The current Linux manpage says this (!):

   Don't output CR.

Here's a snippet that demonstrates Linux's behavior (tl;dr it's just like the
other operating systems):

   $ stty -icanon -onlcr -icrnl -echo onlret onocr; cat
   this is some text			(^J pressed)
                    and some more	(^M pressed before additional text)

The first flags (-icanon -onlcr -icrnl -echo), combined with cat, ensure that
our keys are sent directly back to the terminal emulator without any translation
or buffering.  The last two (ONLRET and ONOCR) are the important ones: ONLRET
makes Linux think that the cursor is at column 0 after the ^J, and ONOCR makes
Linux ignore the following ^M.

---
 man3/termios.3 | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/man3/termios.3 b/man3/termios.3
index c11937458..20641f14d 100644
--- a/man3/termios.3
+++ b/man3/termios.3
@@ -203,7 +203,9 @@ Map CR to NL on output.
 Don't output CR at column 0.
 .TP
 .B ONLRET
-Don't output CR.
+The NL character is assumed to do the carriage-return function;
+the kernel's idea of the current column is set to 0
+after both NL and CR.
 .TP
 .B OFILL
 Send fill characters for a delay, rather than using a timed delay.
-- 
2.34.0

---
 man3/termios.3 | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/man3/termios.3 b/man3/termios.3
index c11937458..20641f14d 100644
--- a/man3/termios.3
+++ b/man3/termios.3
@@ -203,7 +203,9 @@ Map CR to NL on output.
 Don't output CR at column 0.
 .TP
 .B ONLRET
-Don't output CR.
+The NL character is assumed to do the carriage-return function;
+the kernel's idea of the current column is set to 0
+after both NL and CR.
 .TP
 .B OFILL
 Send fill characters for a delay, rather than using a timed delay.
-- 
2.34.1


             reply	other threads:[~2022-01-01 22:56 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-01 22:55 Simon Branch [this message]
2022-01-25 17:34 ` [PATCH] termios.3: Clarify ONLRET Alejandro Colomar (man-pages)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220101225523.11689-1-simonmbranch@gmail.com \
    --to=simonmbranch@gmail.com \
    --cc=alx.manpages@gmail.com \
    --cc=linux-man@vger.kernel.org \
    --cc=mtk.manpages@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.