git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: "less -F" is broken

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
Aug 15, 2018, 21:57 UTC
Message-ID
<CA+55aFxjUsvhHwQGthGiLr537BGHkd-LECXVv8KzBTMMCo1bKQ@mail.gmail.com>
In-Reply-To
<87k1orqpxj.fsf@evledraar.gmail.com>

On Wed, Aug 15, 2018 at 2:29 PM Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:

Show 7 quoted lines
>
> Downloading & trying versions of it locally reveals that it's as of
> version 520, not 530. The last version before 520 is 487. Presumably
> it's covered by this item in the changelog:
>
>     Don't output terminal init sequence if using -F and file fits on one
>     screen[1]

Side note: that's sad, because we already use X in the default exactly for that reason.

So apparently "less" was broken for us to fix something that we already had long solved. The code basically tried to do "automatic X when F is set".

And all that line_count stuff (which is what breaks) is pointless when -X is already given.

That does give a possible fix: just stop doing the line_count thing if no_init is set.

So "-F" would continue to be broken, but "-FX" would work.
Something like the attached patch, perhaps?
            Linus
 main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/main.c b/main.c
index 179bd78..961a9db 100644
--- a/main.c
+++ b/main.c
@@ -59,6 +59,7 @@ extern int	missing_cap;
 extern int	know_dumb;
 extern int	pr_type;
 extern int	quit_if_one_screen;
+extern int	no_init;
 
 
 /*
@@ -274,7 +275,7 @@ main(argc, argv)
 	{
 		if (edit_stdin())  /* Edit standard input */
 			quit(QUIT_ERROR);
-		if (quit_if_one_screen)
+		if (quit_if_one_screen && !no_init)
 			line_count = get_line_count();
 	} else 
 	{
Previous: Linus TorvaldsNext: Ævar Arnfjörð Bjarmason
Message 5 of 9 in “"less -F" is broken”
  1. Linus TorvaldsAug 15, 2018
  2. Stefan BellerAug 15, 2018
  3. Ævar Arnfjörð BjarmasonAug 15, 2018
  4. Linus TorvaldsAug 15, 2018
  5. Linus TorvaldsAug 15, 2018
  6. Ævar Arnfjörð BjarmasonAug 16, 2018
  7. Mark NudelmanAug 16, 2018
  8. Linus TorvaldsAug 16, 2018
  9. Mark NudelmanAug 20, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.