Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 7 Aug 2007 09:41:03 -0400 (EDT)
From:      Daniel Eischen <deischen@freebsd.org>
To:        Ted Lindgreen <ted@tednet.nl>
Cc:        freebsd-current@freebsd.org, delphij@freebsd.org
Subject:   Re: Recent change in less(1)
Message-ID:  <Pine.GSO.4.64.0708070922200.12941@sea.ntplx.net>
In-Reply-To: <200708071048.l77AmHoW002100@omval.tednet.nl>
References:  <200708071048.l77AmHoW002100@omval.tednet.nl>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, 7 Aug 2007, Ted Lindgreen wrote:

> Hi,
>
> The recent change in the behaviour of less(1)
>
> <ted@alpha:2> rcsdiff -u -r1.9 -r1.10 /home/ncvs/src/contrib/less/main.c,v
> ===================================================================
> RCS file: /home/ncvs/src/contrib/less/main.c,v
> retrieving revision 1.9
> retrieving revision 1.10
> diff -u -r1.9 -r1.10
> --- main.c      2007/06/23 15:28:00     1.9
> +++ main.c      2007/08/04 13:16:09     1.10
> @@ -165,7 +165,7 @@
>                quit(QUIT_OK);
>        }
>
> -       if (less_is_more && get_quit_at_eof())
> +       if (less_is_more || get_quit_at_eof())
>                no_init = quit_if_one_screen = TRUE;
>
> wonders me a little.
>
> Is this really the desired behaviour?

Yes, I believe so.  This change in less/screen.c:

$ cvs diff -u -r1.7 -r1.8 screen.c
...

-       /*
-        * This loses for terminals with termcap entries with ti/te strings
-        * that switch to/from an alternate screen, and we're in quit_at_eof
-        * (eg, more(1)).
-        */
-       if (!quit_at_eof && !less_is_more) {
-               sc_init = ltgetstr("ti", &sp);
-               sc_deinit = ltgetstr("te", &sp);
-       }
-
+       sc_init = ltgetstr("ti", &sp);
         if (sc_init == NULL)
                 sc_init = "";

+       sc_deinit= ltgetstr("te", &sp);
         if (sc_deinit == NULL)
                 sc_deinit = "";

and this change in less/main.c:

$ cvs -R diff -u -r1.8 -r1.9 main.c
...

  extern int     missing_cap;
  extern int     know_dumb;
  extern int     quit_if_one_screen;
+extern int     no_init;
  extern int     pr_type;


@@ -165,7 +166,7 @@
         }

         if (less_is_more && get_quit_at_eof())
-               quit_if_one_screen = TRUE;
+               no_init = quit_if_one_screen = TRUE;

attempted to keep historical more(1) behavior, but it didn't work correctly.
Boolean algebra:

   (!A && !B) == !(A || B)

So (!quit_at_eof && !less_is_more) == !(less_is_more || get_quit_at_eof()).

> If so I have a question: how to obtain the former behaviour of the -e
> switch, i.e. quit when EOF is hit twice always (thus whether or not
> when the file happens to fit on a single page)?

Perhaps:

 	if (less_is_more) {
 		no_init = TRUE;
 		if (get_quit_at_eof())
 			quit_if_one_screen = TRUE;
 	}

-- 
DE



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.GSO.4.64.0708070922200.12941>